ModuleFactory

open class ModuleFactory

The ModuleFactory protocol is a factory of that loads dependency graph.

The code that generates dependency graph should be written on load() method.

Public

  • Load the dependency graph on container.

    Declaration

    Swift

    open func load(context: AppContext)

    Parameters

    context

    Instance of AppContext.

  • Unload the dependency graph on container.

    Declaration

    Swift

    open func unload()
  • Reset container components.

    Declaration

    Swift

    public func reset()
  • Register in DI graph.

    By default, it is called from automatically generated code via Deli binary.

    Declaration

    Swift

    @discardableResult
    public func register<T>(
        _ type: T.Type,
        resolver: @escaping Resolver,
        qualifier: String,
        scope: Scope
    ) -> Linker<T>

    Parameters

    type

    The dependency type to resolve.

    resolver

    The closure to specify how to resolve with the dependencies of the type. It is invoked when needs to instantiate the instance.

    qualifier

    The qualifier.

    scope

    It is specify the way that manages the lifecycle.

    Return Value

    Returns a Linker for specifying the Type to allow access to resolve the registered type.

  • Lazy register in DI graph.

    By default, it is called from automatically generated code via Deli binary.

    Declaration

    Swift

    @discardableResult
    public func registerLazy<T>(
        _ type: T.Type,
        resolver: @escaping Resolver,
        injector: @escaping (T) -> (),
        qualifier: String,
        scope: Scope
    ) -> Linker<T>

    Parameters

    type

    The dependency type to resolve.

    resolver

    The closure to specify how to instantiate the instance.

    injector

    The closure to specify how to inject with the dependencies of the type.

    qualifier

    The qualifier.

    scope

    It is specify the way that manages the lifecycle.

    Return Value

    Returns a Linker for specifying the Type to allow access to resolve the registered type.

  • Register factory in DI graph.

    It is automatically managed as a prototype scope. By default, it is called from automatically generated code via Deli binary.

    Declaration

    Swift

    @discardableResult
    public func registerFactory<T>(
        _ type: T.Type,
        resolver: @escaping FactoryResolver,
        qualifier: String
    ) -> Linker<T>

    Parameters

    type

    The dependency type to resolve.

    resolver

    The closure to specify how to resolve with the dependencies of the type. It is invoked when needs to instantiate the instance.

    qualifier

    The qualifier.

    Return Value

    Returns a Linker for specifying the Type to allow access to resolve the registered type.

  • Lazy register factory in DI graph.

    It is automatically managed as a prototype scope. By default, it is called from automatically generated code via Deli binary.

    Declaration

    Swift

    @discardableResult
    public func registerLazyFactory<T>(
        _ type: T.Type,
        resolver: @escaping FactoryResolver,
        injector: @escaping (T) -> (),
        qualifier: String
    ) -> Linker<T>

    Parameters

    type

    The dependency type to resolve.

    resolver

    The closure to specify how to instantiate the instance.

    injector

    The closure to specify how to inject with the dependencies of the type.

    qualifier

    The qualifier.

    Return Value

    Returns a Linker for specifying the Type to allow access to resolve the registered type.

  • Load property in container

    Declaration

    Swift

    public func loadProperty(_ properties: [String : Any])

    Parameters

    properties

    Property dictionary.

Lifecycle

  • Pre-generated initialize method for instantiating.

    Declaration

    Swift

    public required init()