MutableInjector

public protocol MutableInjector : Injector

An Injector that additionally is mutable.

  • Additionally provides a value given as a factory for a given Key.

    Declaration

    Swift

    mutating func provide(key: Key, usingFactory factory: @escaping (inout Self) throws -> Providable)

    Parameters

    key

    The Key, an InjectedProvider is constructed of.

    factory

    Creates a value out of a new Injector.

  • Resolves InjectedProvider.value for a given Key.

    Declaration

    Swift

    mutating func resolve(key: Key) throws -> Providable

    Parameters

    key

    The Key that has been used previously.

    Return Value

    The previously added Providable.

  • Ensures a given key is not provided anymoure.

    Declaration

    Swift

    mutating func revoke(key: Key)

    Parameters

    key

    The key that shall be removed.

  • provide(for:usingFactory:) Extension method

    Additionally provides a value given as a factory for a given Provider.

    Declaration

    Swift

    public mutating func provide<Value: Providable>(
      for provider: Provider<Key, Value>, usingFactory factory: @escaping (inout Self) throws -> Value
    )

    Parameters

    provider

    The Provider, an InjectedProvider is constructed of.

    factory

    Creates a value out of a new Injector.

  • revoke(for:) Extension method

    Revokes the value of a given provider.

    Declaration

    Swift

    public mutating func revoke<Value>(for provider: Provider<Key, Value>)

    Parameters

    provider

    The provider that’s value shall be revoked.

  • resolve(from:) Extension method

    Resolves InjectedProvider.value for a given Provider.

    Declaration

    Swift

    public mutating func resolve<Value>(from provider: Provider<Key, Value>) throws -> Value

    Parameters

    provider

    The Provider that has been used previously.

    Return Value

    The previously added Providable.

  • provide(_:for:) Extension method

    Additionally provides a value for a given Provider.

    Declaration

    Swift

    public mutating func provide<Value: Providable>(
      _ instance: @autoclosure @escaping () -> Value,
      for provider: Provider<Key, Value>
    )

    Parameters

    instance

    The provided Providable. Depending on Self, evaluated lazily.

    provider

    The Provider, an InjectedProvider will be constructed of.

  • globalize() Extension method

    Wraps self into a GlobalInjector.

    Declaration

    Swift

    public func globalize() -> GlobalInjector<Key>

    Return Value

    GlobalInjector that wraps self.

  • erase() Extension method

    Erases the specific MutableInjector Type.

    Declaration

    Swift

    public func erase() -> AnyInjector<Key>

    Return Value

    AnyInjector that wraps self.

  • compose(_:) Extension method

    Composes self with another given MutableInjector.

    Declaration

    Swift

    public func compose<I>(_ right: I) -> ComposedInjector<Key> where I : MutableInjector, Self.Key == I.Key

    Parameters

    right

    The secondary MutableInjector.

    Return Value

    AnyInjector that wraps self.

Available where Self: AnyObject

  • provide(_:for:) Extension method

    Additionally provides a value for a given Provider.

    Declaration

    Swift

    public func provide<Value: Providable>(
      _ instance: @autoclosure @escaping () -> Value,
      for provider: Provider<Key, Value>
    )

    Parameters

    instance

    The provided Providable. Depending on Self, evaluated lazily.

    provider

    The Provider, an InjectedProvider will be constructed of.