openURL
A dependency that opens a URL.
- iOS
- 14+
- macOS
- 11+
- tvOS
- 14+
- watchOS
- 7+
var openURL: OpenURLEffect { get set }
A dependency that opens a URL.
var openURL: OpenURLEffect { get set }
s12Dependencies16DependencyValuesV7openURLAA13OpenURLEffectVvp
What are these?180FL
import Dependencies
A dependency management library inspired by SwiftUI’s “environment.”
struct DependencyValues
A collection of dependencies that is globally available.
struct OpenURLEffect
var assert: any AssertionEffect { get }
A dependency for handling assertions.
var assertionFailure: any AssertionFailureEffect { get }
A dependency for failing an assertion.
var calendar: Calendar { get set }
The current calendar that features should use when handling dates.
var context: DependencyContext { get set }
The current dependency context.
var continuousClock: any Clock<Duration> { get set }
The current clock that features should use when a ContinuousClock
would be appropriate.
var date: DateGenerator { get set }
A dependency that returns the current date.
var fireAndForget: FireAndForget { get }
A dependency for firing off an unstructured task.
var locale: Locale { get set }
var mainQueue: AnySchedulerOf<DispatchQueue> { get set }
The “main” queue.
var mainRunLoop: AnySchedulerOf<RunLoop> { get set }
The “main” run loop.
var precondition: any AssertionEffect { get }
A dependency for handling preconditions.
var suspendingClock: any Clock<Duration> { get set }
The current clock that features should use when a SuspendingClock
would be appropriate.
var timeZone: TimeZone { get set }
The current time zone that features should use when handling dates.
var urlSession: URLSession { get set }
The URL session that features should use to make URL requests.
var uuid: UUIDGenerator { get set }
A dependency that generates UUIDs.
var withRandomNumberGenerator: WithRandomNumberGenerator { get set }
A dependency that yields a random number generator to a closure.
init()
Creates a dependency values instance.
init(context: DependencyContext)
static var _current: DependencyValues { get }
static var live: `Self` { get }
A collection of “live” dependencies.
static var preview: `Self` { get }
A collection of “preview” dependencies.
static var test: `Self` { get }
A collection of “test” dependencies.
var cachedValues: CachedValues
subscript<Key>(type: Key.Type) -> Key.Value where Key : TestDependencyKey { get set }
subscript<Key>(key: Key.Type, fileID: StaticString = #fileID, filePath: StaticString = #filePath, line: UInt = #line, column: UInt = #line, function: StaticString = #function) -> Key.Value where Key : TestDependencyKey { get set }
Accesses the dependency value associated with a custom key.
struct Continuation
A capture of dependencies to use in an escaping context.
static func withTestValues<R>(_ updateValuesForOperation: (inout `Self`) throws -> Void, assert operation: () throws -> R) rethrows -> R
static func withTestValues<R>(_ updateValuesForOperation: (inout `Self`) async throws -> Void, assert operation: () async throws -> R) async rethrows -> R where R : Sendable
static func withValue<Value, R>(_ keyPath: WritableKeyPath<DependencyValues, Value>, _ value: @autoclosure () -> Value, operation: () throws -> R) rethrows -> R
static func withValue<Value, R>(_ keyPath: WritableKeyPath<DependencyValues, Value>, _ value: @autoclosure () -> Value, operation: () async throws -> R) async rethrows -> R where R : Sendable
static func withValues<R>(_ updateValuesForOperation: (inout `Self`) throws -> Void, operation: () throws -> R) rethrows -> R
static func withValues<R>(_ updateValuesForOperation: (inout `Self`) throws -> Void, operation: () async throws -> R) async rethrows -> R where R : Sendable
func resetCache()