Injector
public protocol Injector
Stores Providable
s associated for corredponding ProvidableKey
s
using Provider
s and internally InjectedProvider
s.
-
The required
ProvidableKey
for injection.Declaration
Swift
associatedtype Key : Hashable
-
Resolves
InjectedProvider.value
for a givenKey
.Throws
InjectionError
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 parameterDeclaration
Swift
func providing(key: Key, usingFactory factory: @escaping (inout Self) throws -> Providable) -> Self
Parameters
key
The
Key
, anInjectedProvider
is constructed of.factory
Creates a value out of a new
Injector
.Return Value
A new
Injector
with contents ofself
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) -
resolving(from:
Extension method) Resolves
InjectedProvider.value
for a givenProvider
.Throws
InjectionError
Parameters
provider
The
Provider
that has been used previously.Return Value
The previously added
Providable
. -
providing(for:
Extension methodusingFactory: ) Creates an instance providing a value as a factory for a given
Provider
.To do
Improve markup for
factory
‘s parameterDeclaration
Swift
public func providing<Value: Providable>( for provider: Provider<Key, Value>, usingFactory factory: @escaping (inout Self) throws -> Value ) -> Self
Parameters
provider
The
Provider
, anInjectedProvider
is constructed of.factory
Creates a value out of a new
Injector
.Return Value
A new
Injector
with contents ofself
and the newly provided value. -
revoking(for:
Extension method) -
copy()
Extension methodBy 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(_:
Extension methodfor: ) 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
, anInjectedProvider
is constructed of.instance
The provided
Providable
. Depending onSelf
, evaluated lazily.Return Value
A new
Injector
with contents ofself
and the newly provided value. -
debugDescription
Extension methodUndocumented
Declaration
Swift
public var debugDescription: String { get }
-
globalized()
Extension methodWraps
self
into aGlobalInjector
.Declaration
Swift
public func globalized() -> GlobalInjector<Key>
Return Value
GlobalInjector
that wrapsself
. -
erased()
Extension methodErases the specific
Injector
Type.Declaration
Swift
public func erased() -> AnyInjector<Key>
Return Value
AnyInjector
that wrapsself
. -
composed(_:
Extension method) Composes
self
with another givenInjector
.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 wrapsself
.