Global dispatchers library
pod 'Astrarium', '~> 5.0'The main idea behind this library is to solve the following problems:
- Make
AppDelegateimplementation 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.
To integrate Astrarium into your app, you need to be inherited your AppDelegate from Astrarium.AppDelegate:
public class AppDelegate: Astrarium.AppDelegateThen you need to override services variable and return list of services ids:
public override var services: [ServiceIds?] { return [
.fabric,
.firebase,
.ui
]
}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()