Injector

public protocol Injector

Stores Providables associated for corredponding ProvidableKeys using Providers and internally InjectedProviders.

  • Key

    The required ProvidableKey for injection.

    Declaration

    Swift

    associatedtype Key : Hashable
  • Resolves InjectedProvider.value for a given Key.

    Declaration

    Swift

    func resolving(key: Key) throws -> Providable

    Parameters

    key

    The Key that has been used previously.

    Return Value

    The previously added Providable.

  • Creates an instance providing a value as a factory for a given Key.

    To do

    Improve markup for factory‘s parameter

    Declaration

    Swift

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

    Parameters

    key

    The Key, an InjectedProvider is constructed of.

    factory

    Creates a value out of a new Injector.

    Return Value

    A new Injector with contents of self and the newly provided value.

  • Creates a new instance that provides all keys except the given one.

    Declaration

    Swift

    func revoking(key: Key) -> Self

    Parameters

    key

    The key that shall be removed.

    Return Value

    A copy that doesn’t contain key.

  • Returns all Keys, that has been injected, regardless wether resolving fails.

    Declaration

    Swift

    var providedKeys: [Key] { get }
  • subscript(_:) Extension method

    Undocumented

    Declaration

    Swift

    public subscript<Value>(provider: Provider<Key, Value>) -> Value? { get }
  • resolving(from:) Extension method

    Resolves InjectedProvider.value for a given Provider.

    Declaration

    Swift

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

    Parameters

    provider

    The Provider that has been used previously.

    Return Value

    The previously added Providable.

  • providing(for:usingFactory:) Extension method

    Creates an instance providing a value as a factory for a given Provider.

    To do

    Improve markup for factory‘s parameter

    Declaration

    Swift

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

    Parameters

    provider

    The Provider, an InjectedProvider is constructed of.

    factory

    Creates a value out of a new Injector.

    Return Value

    A new Injector with contents of self and the newly provided value.

  • revoking(for:) Extension method

    Revokes the value of a given provider.

    Declaration

    Swift

    public func revoking<Value>(for provider: Provider<Key, Value>) -> Self

    Parameters

    provider

    The provider that’s value shall be revoked.

    Return Value

    A new instance without any value for the provider.

  • copy() Extension method

    By default implements InjectorDerivingFromMutableInjector.copy() for all value types by just returning self.

    Declaration

    Swift

    public func copy() -> Self
  • contains(_:) Extension method

    Determines wether a specific key has been provided.

    Declaration

    Swift

    public func contains(_ key: Key) -> Bool

    Parameters

    key

    The key that shall be tested for.

    Return Value

    true if provided. Will also return true if the key cannot be resolved properly.

  • providing(_:for:) Extension method

    Creates an instance providing a value for a given Provider.

    Declaration

    Swift

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

    Parameters

    provider

    The Provider, an InjectedProvider is constructed of.

    instance

    The provided Providable. Depending on Self, evaluated lazily.

    Return Value

    A new Injector with contents of self and the newly provided value.

  • debugDescription Extension method

    Undocumented

    Declaration

    Swift

    public var debugDescription: String { get }
  • globalized() Extension method

    Wraps self into a GlobalInjector.

    Declaration

    Swift

    public func globalized() -> GlobalInjector<Key>

    Return Value

    GlobalInjector that wraps self.

  • erased() Extension method

    Erases the specific Injector Type.

    Declaration

    Swift

    public func erased() -> AnyInjector<Key>

    Return Value

    AnyInjector that wraps self.

  • composed(_:) Extension method

    Composes self with another given Injector.

    Declaration

    Swift

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

    Parameters

    right

    The secondary Injector.

    Return Value

    AnyInjector that wraps self.