ComposedInjector
public struct ComposedInjector<K> : InjectorDerivingFromMutableInjector where K : Hashable
Wraps two given MutableInjector
s into one.
By default all operations will be first delegated to ComposedInjector.left
and thereafter to ComposedInjector.right
.
May throw ComposedInjectionError
as InjectionError.customError
.
If a reference typed MutableInjector will be used,
a copy will be created on ComposedInjector.provide(key:usingFactory:)
,
but there won’t be created a copy on ComposedInjector.init(left:right:)
.
-
Declaration
Swift
public typealias Key = K
-
The first
Injector
that shall be wrapped.Declaration
Swift
public var left: AnyInjector<K>
-
The second
Injector
that shall be wrapped.Declaration
Swift
public var right: AnyInjector<K>
-
Initializes
AnyMutableInjector
with a givenMutableInjector
.Declaration
Parameters
left
The default
MutableInjector
that shall be wrapped.right
The fallback
MutableInjector
that shall be wrapped. -
Declaration
Swift
public mutating func resolve(key: Key) throws -> Providable
-
Declaration
Swift
public mutating func provide( key: Key, usingFactory factory: @escaping (inout ComposedInjector) throws -> Providable )
-
Declaration
Swift
public var providedKeys: [K] { get }
Return Value
The union of the left and right
Injector.providedKeys
. -
Declaration
Swift
public mutating func revoke(key: K)
-
Returns
MutableInjector.resolve(key:)
invoked onComposedInjector.left
.Throws
Just passes all errors.Declaration
Swift
public mutating func resolveLeft(key: Key) throws -> Providable
-
Returns
MutableInjector.resolve(key:)
invoked onComposedInjector.right
.Throws
Just passes all errors.Declaration
Swift
public mutating func resolveRight(key: Key) throws -> Providable
-
Calls both,
ComposedInjector.resolveLeft(key:)
andComposedInjector.resolveRight(key:)
.Declaration
Swift
public mutating func resolveBoth(key: Key) throws -> (Providable, Providable)
Return Value
Both results.
-
Resolves
InjectedProvider.value
for a givenProvider
. Will be performed on the.left
Injector
.Throws
InjectionError
Declaration
Swift
public mutating func resolveLeft<Value: Providable>( from provider: Provider<Key, Value> ) throws -> Value
Parameters
provider
The
Provider
that has been used previously.Return Value
The previously added
Providable
. -
Resolves
InjectedProvider.value
for a givenProvider
. Will be performed on the.right
Injector
.Throws
InjectionError
Declaration
Swift
public mutating func resolveRight<Value: Providable>( from provider: Provider<Key, Value> ) throws -> Value
Parameters
provider
The
Provider
that has been used previously.Return Value
The previously added
Providable
. -
Resolves
InjectedProvider.value
for a givenProvider
. Will be performed on the.left
and thereafter on the.right
Injector
.Declaration
Swift
public mutating func resolveBoth<Value: Providable>( from provider: Provider<Key, Value> ) throws -> (Value, Value)
Parameters
provider
The
Provider
that has been used previously.Return Value
The previously added
Providable
. -
Declaration
Swift
public mutating func provideLeft( key: Key, usingFactory factory: @escaping (inout ComposedInjector) throws -> Providable )
-
Declaration
Swift
public mutating func provideRight( key: Key, usingFactory factory: @escaping (inout ComposedInjector) throws -> Providable )
-
Invokes
MutableInjector.provide(key:usingFactory:)
onComposedInjector.left
andComposedInjector.left
.Declaration
Swift
public mutating func provideBoth( key: Key, usingFactory factory: @escaping (inout ComposedInjector) throws -> Providable )
-
Additionally provides a value given as a factory for a given
Provider
. This will only be performed on the.left
Injector
.Declaration
Swift
public mutating func provideLeft<Value: Providable>( for provider: Provider<Key, Value>, usingFactory factory: @escaping (inout ComposedInjector) throws -> Value )
Parameters
provider
The
Provider
, anInjectedProvider
is constructed of.factory
Creates a value out of a new
Injector
. -
Additionally provides a value given as a factory for a given
Provider
. This will only be performed on the.right
Injector
.Declaration
Swift
public mutating func provideRight<Value: Providable>( for provider: Provider<Key, Value>, usingFactory factory: @escaping (inout ComposedInjector) throws -> Value )
Parameters
provider
The
Provider
, anInjectedProvider
is constructed of.factory
Creates a value out of a new
Injector
. -
Additionally provides a value given as a factory for a given
Provider
. This will only be performed on the.left
and thereafter on the.right
Injector
.Declaration
Swift
public mutating func provideBoth<Value: Providable>( for provider: Provider<Key, Value>, usingFactory factory: @escaping (inout ComposedInjector) throws -> Value )
Parameters
provider
The
Provider
, anInjectedProvider
is constructed of.factory
Creates a value out of a new
Injector
. -
Invokes
MutableInjector.revoke(key:)
onComposedInjector.left
.Declaration
Swift
public mutating func revokeLeft(key: K)
Parameters
key
The key to be removed.
-
Invokes
MutableInjector.revoke(key:)
onComposedInjector.right
.Declaration
Swift
public mutating func revokeRight(key: K)
Parameters
key
The key to be removed.
-
Invokes
MutableInjector.revoke(key:)
onComposedInjector.left
andComposedInjector.right
.Declaration
Swift
public mutating func revokeBoth(key: K)
Parameters
key
The key to be removed.
-
Resolves
InjectedProvider.value
for a givenProvider
. Will be performed on the.left
Injector
.Throws
InjectionError
Declaration
Swift
public func resolvingLeft<Value: Providable>( from provider: Provider<Key, Value> ) throws -> Value
Parameters
provider
The
Provider
that has been used previously.Return Value
The previously added
Providable
. -
Resolves
InjectedProvider.value
for a givenProvider
. Will be performed on the.right
Injector
.Throws
InjectionError
Declaration
Swift
public func resolvingRight<Value: Providable>( from provider: Provider<Key, Value> ) throws -> Value
Parameters
provider
The
Provider
that has been used previously.Return Value
The previously added
Providable
. -
Resolves
InjectedProvider.value
for a givenProvider
. Will be performed on the.left
and thereafter on the.right
Injector
.Declaration
Swift
public func resolvingBoth<Value: Providable>(from provider: Provider<Key, Value>) throws -> ( Value, Value )
Parameters
provider
The
Provider
that has been used previously.Return Value
A tuple of the left and right
Providable
, that have been added. -
Additionally provides a value given as a factory for a given
Provider
. This will only be performed on the.left
Injector
.Declaration
Swift
public func providingLeft<Value: Providable>( for provider: Provider<Key, Value>, usingFactory factory: @escaping (inout ComposedInjector) throws -> Value ) -> ComposedInjector
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. -
Additionally provides a value given as a factory for a given
Provider
. This will only be performed on the.right
Injector
.Declaration
Swift
public func providingRight<Value: Providable>( for provider: Provider<Key, Value>, usingFactory factory: @escaping (inout ComposedInjector) throws -> Value ) -> ComposedInjector
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. -
Additionally provides a value given as a factory for a given
Provider
. This will only be performed on the.left
and thereafter on the.right
Injector
.Declaration
Swift
public func providingBoth<Value: Providable>( for provider: Provider<Key, Value>, usingFactory factory: @escaping (inout ComposedInjector) throws -> Value ) -> ComposedInjector
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. -
Invokes
Injector.revoking(key:)
onComposedInjector.left
.Declaration
Swift
public func revokingLeft(key: K) -> ComposedInjector
Parameters
key
The key to be removed.
Return Value
A
ComposedInjector
that revoked the key onComposedInjector.left
. -
Invokes
Injector.revoking(key:)
onComposedInjector.right
.Declaration
Swift
public func revokingRight(key: K) -> ComposedInjector
Parameters
key
The key to be removed.
Return Value
A
ComposedInjector
that revoked the key onComposedInjector.right
. -
Invokes
Injector.revoking(key:)
onComposedInjector.left
andComposedInjector.right
.Declaration
Swift
public func revokingBoth(key: K) -> ComposedInjector
Parameters
key
The key to be removed.
Return Value
A
ComposedInjector
that revoked the key onComposedInjector.left
andComposedInjector.right
. -
Creates an instance providing a value for a given
Provider
. This will only be performed onComposedInjector.left
.Declaration
Swift
public func providingLeft<Value: Providable>( _ instance: @autoclosure @escaping () -> Value, for provider: Provider<Key, Value> ) -> ComposedInjector
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. -
Creates an instance providing a value for a given
Provider
. This will only be performed on theComposedInjector.right
.Declaration
Swift
public func providingRight<Value: Providable>( _ instance: @autoclosure @escaping () -> Value, for provider: Provider<Key, Value> ) -> ComposedInjector
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. -
Creates an instance providing a value for a given
Provider
. This will only be performed onComposedInjector.left
and thereafter onComposedInjector.right
.Declaration
Swift
public func providingBoth<Value: Providable>( _ instance: @autoclosure @escaping () -> Value, for provider: Provider<Key, Value> ) -> ComposedInjector
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. -
Additionally provides a value for a given
Provider
. This will only be performed onComposedInjector.left
.Declaration
Swift
public mutating func provideLeft<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. -
Additionally provides a value for a given
Provider
. This will only be performed onComposedInjector.right
.Declaration
Swift
public mutating func provideRight<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. -
Additionally provides a value for a given
Provider
. This will only be performed onComposedInjector.left
and thereafter onComposedInjector.right
.Declaration
Swift
public mutating func provideBoth<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.