continuousClock
The current clock that features should use when a ContinuousClock
would be appropriate.
- iOS
- 16+
- macOS
- 13+
- tvOS
- 16+
- watchOS
- 9+
var continuousClock: any Clock<Duration> { get set }
This clock is type-erased so that it can be swapped out in previews and tests for another clock, like ImmediateClock
and TestClock
that come with the Clocks library (which is automatically imported and available when you import this library).
By default, a live ContinuousClock
is supplied. When used in a testing context, an UnimplementedClock
is provided, which generates an XCTest failure when used, unless explicitly overridden using withDependencies(_:operation:)
:
// Provision model with overridden dependencies
let model = withDependencies {
$0.continuousClock = ImmediateClock()
} operation: {
FeatureModel()
}
// Make assertions with model...
See suspendingClock
to override a feature’s SuspendingClock
, instead.