initApplicationEventBus method

  1. @protected
Future<void> initApplicationEventBus()

Initializes the ApplicationEventBus for this context.

This sets up the event publishing system. By default, it creates a SimpleApplicationEventBus and registers it in the pod factory. Subclasses may override this to supply a custom implementation.

This is part of Jetleaf – a framework which developers can use to build web applications.

Implementation

@protected
Future<void> initApplicationEventBus() async {
  if (podFactory != null && await containsLocalPod(APPLICATION_EVENT_BUS_POD_NAME)) {
    _applicationEventBus = await getPod<ApplicationEventBus>(APPLICATION_EVENT_BUS_POD_NAME);
  } else {
    final aeb = Class<SimpleApplicationEventBus>(null, PackageNames.CORE);
    _applicationEventBus = SimpleApplicationEventBus(podFactory);

    await registerSingleton(
      APPLICATION_EVENT_BUS_POD_NAME,
      aeb,
      object: ObjectHolder<ApplicationEventBus>(
        _applicationEventBus!,
        packageName: PackageNames.CORE,
        qualifiedName: aeb.getQualifiedName()
      )
    );
  }

  return Future.value();
}