-
Notifications
You must be signed in to change notification settings - Fork 10
Dependencies
This type acts as a namespace to reference your dependencies.
public struct Dependencies 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 Dependencies {
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.
Use this static method to reset all aliases you may have set between dependencies.
You typically call this method during the setUp() method of some XCTestCase subclass:
public static func clearAliases() class SomeFeatureTests: XCTextCase {
override func setUp() {
super.setUp()
Dependencies.clearAliases()
}
// …
}Use this static method to reset all aliases you may have set between dependencies.
You typically call this method during the setUp() method of some XCTestCase subclass:
public static func clearAliases() class SomeFeatureTests: XCTextCase {
override func setUp() {
super.setUp()
Dependencies.clearAliases()
}
// …
}Use this static method to reset all global depedencies to their default values.
You typically call this method during the setUp() method of some XCTestCase subclass:
public static func reset() class SomeFeatureTests: XCTextCase {
override func setUp() {
super.setUp()
Dependencies.reset()
}
// …
}Generated at 2022-08-22T21:22:01+0000 using swift-doc 1.0.0-rc.1.