Astrarium 5.1.0

Astrarium 5.1.0

Maintained by Sergei Mikhan, Eugene Filipkov, Dmitry Duleba.



Astrarium 5.1.0

  • By
  • Dzmitry Duleba

Astrarium

Global dispatchers library

Version License Platform

Installation

pod 'Astrarium', '~> 5.0'

Main concept

The main idea behind this library is to solve the following problems:

  • Make AppDelegate implementation cleaner;
  • Stop providing interface over managers/handlers as singleton object;

The main concept of Astrarium is Service. A service is a statefull object in most of the cases. It has the same lifetime as the application. Access to these services is done by ServiceIdentifier using Dispatcher.

Initialization

To integrate Astrarium into your app, you need to be inherited your AppDelegate from Astrarium.AppDelegate:

public class AppDelegate: Astrarium.AppDelegate

Then you need to override services variable and return list of services ids:

  public override var services: [ServiceIds?] { return [
    .fabric,
    .firebase,
    .ui
    ]
  }

Service implementation

Service itself has access to any AppDelegate callbacks to perform any action your service needs. Here is the simple example of UI service:

extension ServiceIds {
  static let ui = ServiceIdentifier<UICoordinator>()
}

final class UICoordinator: AppService {
  func someFancyMethod() {}
  func setup(with launchOptions: LaunchOptions) {}
}

Then you can access instance of service:

Services[.ui]?.someFancyMethod()