Swiftpack.co -  netcosports/Astrarium as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
netcosports/Astrarium
iOS Library for global dispatchers
.package(url: "https://github.com/netcosports/Astrarium.git", from: "5.1.1")

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()

GitHub

link
Stars: 4
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Swift 5.0
2 years ago
  • Support for Swift 5.0
  • Possibility to use custom AppService init

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API