-
Notifications
You must be signed in to change notification settings - Fork 10
DerivedEnvironment
Use this property wrapper to declare child ComposableEnvironment
in a
ComposableEnvironment
subclass.
@propertyWrapper
public final class DerivedEnvironment<Environment> where Environment: ComposableEnvironment
You only need to specify the subclass used and its name. You don't need to instantiate the
subclass. For example, if ChildEnvironment
is a ComposableEnvironment
subclass, you can
install a representant in ParentEnvironment
as:
class ParentEnvironment: ComposableEnvironment {
@DerivedEnvironment<ChildEnvironment> var child
}.
This exposes a var child: ChildEnvironment
read-only property in the ParentEnvironment
.
This child environment inherits the current dependencies of all its ancestor. They can be
exposed using the Dependency
property wrapper.
You can also use this property wrapper is to define DependencyAlias
's using the
AliasBuilder
closure from the intializers:
struct ParentEnvironment: GlobalEnvironment {
@DerivedEnvironment<ChildEnvironment>(aliases: {
$0.alias(\.main, to: \.mainQueue)
}) var child
}
See DerivedEnvironment
discussion
public init(
wrappedValue: Environment,
aliases: (
(AliasBuilder<Environment>)
-> AliasBuilder<Environment>
)? = nil
)
See DerivedEnvironment
discussion
public init(aliases: ((AliasBuilder<Environment>) -> AliasBuilder<Environment>)? = nil)
See DerivedEnvironment
discussion
public init(
wrappedValue: Environment,
aliases: ((AliasBuilder<Environment>) -> AliasBuilder<Environment>)? = nil
)
See DerivedEnvironment
discussion
public init(aliases: ((AliasBuilder<Environment>) -> AliasBuilder<Environment>)? = nil)
@available(
*, unavailable,
message: "@DerivedEnvironment should be used in a ComposableEnvironment class."
)
public var wrappedValue: Environment
public var wrappedValue: Environment
Generated at 2022-08-22T21:22:01+0000 using swift-doc 1.0.0-rc.1.