-
Notifications
You must be signed in to change notification settings - Fork 10
ComposableDependencies
tgrapperon edited this page Aug 31, 2021
·
4 revisions
This type acts as a namespace to reference your dependencies.
public struct ComposableDependencies To declare a dependency, create a DependencyKey, and declare a computed property in this
type like you would declare a custom EnvironmentValue in SwiftUI. For example, if
UUIDGeneratorKey is a DependencyKey with DependencyKey/Value == () -> UUID:
extension ComposableDependencies {
var uuidGenerator: () -> UUID {
get { self[UUIDGeneratorKey.self] }
set { self[UUIDGeneratorKey.self] = newValue }
}
}This dependency can then be referenced by its keypath \.uuidGenerator when invoking the
Dependency property wrapper in some ComposableEnvironment subclass.
Generated at 2022-08-22T21:22:01+0000 using swift-doc 1.0.0-rc.1.