initialize method

Future<void> initialize(
  1. Initializer initializer,
  2. IIsolateFactory isolateFactory
)

Initializer which is used to create Isolate and initialize UIIsolateManager and IsolateManager.

Takes user initializer function which will be launched in Isolate and isolateFactory which is used to create new Isolate and initialize communication between it and UI Isolate.

Implementation

Future<void> initialize(
  Initializer initializer,
  IIsolateFactory isolateFactory,
) async {
  // Close current isolate.
  await UIIsolateManager.instance?.dispose();

  final createResult = await isolateFactory.create(
    _isolatedBlocRunner,
    initializer,
  );

  final uiIsolateManager = UIIsolateManager(
    createResult,
  );

  // Complete initialization.
  await uiIsolateManager.initialize();
}