Package: effect
Module: Clock
Accesses the current Clock service and uses it to run the provided function.
When to use
Use when you need the full Clock service interface to perform multiple time operations or call unsafe variants within a single effect.
Example (Accessing the current Clock service)
import { Clock, Effect } from "effect"
const program = Clock.clockWith((clock) =>
Effect.sync(() => {
const currentTime = clock.currentTimeMillisUnsafe()
console.log(`Current time: ${currentTime}`)
return currentTime
})
)
See
Clock for the service referencecurrentTimeMillis for convenience accessor that returns millisecondscurrentTimeNanos for convenience accessor that returns nanosecondsSignature
declare const clockWith: <A, E, R>(f: (clock: Clock) => Effect<A, E, R>) => Effect<A, E, R>
Since v2.0.0