A quick service locator for the Apple platform, made to be the easiest and simplest way to use
Swift package manager
https://github.com/frankois944/QuickServiceLocator.git
// registering and resolving
@QuickSL(register: DummyService())
var dummyService: DummyServiceProtocol
// even
@QuickSL(register: DummyService())
var dummyTest2: DummyService
// only resolving
@QuickSL var dummyService: DummyServiceProtocol
// registering
QuickServiceLocator.register(DummyServiceProtocol.self, DummyService())
// resolving
let instance: DummyServiceProtocol = QuickServiceLocator.locate()
QuickServiceLocator.unregister(DummyServiceProtocol.self)
QuickServiceLocator.isRegister(DummyServiceProtocol.self)
By default, every services are registered in a lazySharedInstance
mode, it means the DummyService
will be created during the resolving step as a singleton.
This behavior can be set during the registering step.
@QuickSL(register: DummyService(), mode: .newInstance)
var dummyService: DummyServiceProtocol
// or
QuickServiceLocator.register(DummyServiceProtocol.self,
mode: .newInstance,
DummyService())