Skip to content

v2.0.5 - App-Level Service Initialization Support

Choose a tag to compare

@pillowsoft pillowsoft released this 03 Jan 17:51
· 7 commits to main since this release

✨ New Feature: App-Level Service Initialization

This release adds support for coordinating app-level service initialization to prevent SignalEffectException during startup.

The Problem

In v2.0.3, we fixed SignalEffectException in the framework's internal services, but apps with their own services (ChatManager, EventFlowService, etc.) could still experience crashes during initialization when those services created effects while the UI's Watch widgets were activating.

The Solution

New appReady Signal Parameter in AppConfig

The framework now supports an optional appReady signal that allows apps to coordinate initialization of all their services before the main UI renders.

Added

AppConfig Enhancement:

  • ✨ New optional appReady: Signal<bool>? parameter
  • Framework waits for BOTH settingsStore.isReady AND appReady before rendering UI
  • Prevents concurrent reactive initialization issues
  • Comprehensive inline documentation with usage example

Files Changed:

  • lib/src/core/app_config.dart - Added appReady parameter with detailed docs
  • lib/src/core/app_shell_runner.dart - Extended initialization guard

Usage Example

// 1. Create an appReady signal
final appReady = signal(false);

// 2. Initialize your services and wait for them
Future<void> initializeServices() async {
  await chatManager.initialize();
  await eventFlowService.initialize();

  // Wait for all service isReady signals
  await Future.doWhile(() async {
    await Future.delayed(Duration(milliseconds: 50));
    return !chatManager.isReady.value || !eventFlowService.isReady.value;
  });

  appReady.value = true;
}

// 3. Pass appReady to AppConfig
void main() async {
  await initializeServices();
  
  runShellApp(
    appConfig: AppConfig(
      appReady: appReady,
      routes: routes,
      title: 'My App',
    ),
  );
}

Migration

For apps experiencing SignalEffectException during initialization:

  1. Add isReady signals to your app services (following the pattern from v2.0.3)
  2. Create an appReady signal
  3. Wait for all service isReady signals before setting appReady.value = true
  4. Pass appReady to AppConfig

No migration required for apps not experiencing initialization issues.

Documentation

  • 📚 Detailed usage example in AppConfig documentation
  • 📚 Migration guide in CHANGELOG.md
  • 📚 Updated CLAUDE.md with v2.0.5 notes

Technical Details

This solves the concurrent reactive initialization problem:

  • Before: App services created effects → Watch widgets activated simultaneously → SignalEffectException
  • After: Framework waits for appReady → All services stable → Watch widgets activate safely

Full Changelog: v2.0.4...v2.0.5