-
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
, anInjectedProvider
is constructed of.factory
Creates a value out of a new
Injector
. -
Resolves
InjectedProvider.value
for a givenKey
.Throws
InjectionError
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:
Extension methodusingFactory: ) 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
, anInjectedProvider
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 givenProvider
.Throws
InjectionError
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(_:
Extension methodfor: ) 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 onSelf
, evaluated lazily.provider
The
Provider
, anInjectedProvider
will be constructed of. -
globalize()
Extension methodWraps
self
into aGlobalInjector
.Declaration
Swift
public func globalize() -> GlobalInjector<Key>
Return Value
GlobalInjector
that wrapsself
. -
erase()
Extension methodErases the specific
MutableInjector
Type.Declaration
Swift
public func erase() -> AnyInjector<Key>
Return Value
AnyInjector
that wrapsself
. -
compose(_:
Extension method) Composes
self
with another givenMutableInjector
.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 wrapsself
.
-
provide(_:
Extension methodfor: ) 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 onSelf
, evaluated lazily.provider
The
Provider
, anInjectedProvider
will be constructed of.