initialize method

Future<void> initialize()

Implementation

Future<void> initialize() async {
  await runAsService(() async {
    for (final factory in _factories) {
      BaseService? service;
      try {
        service = factory();
        await service.initialize();
        _services.add(service);
      } catch (e, stack) {
        if (service == null) {
          _onError('Error while creating service instance.', e, stack,
              failWithServices);
        } else {
          _onError(
              'Error while initializing service instance of ${service.runtimeType}.',
              e,
              stack,
              failWithServices);
        }

        if (failWithServices) {
          rethrow;
        }
      }
    }
  });
}