Hyperlinkv0.8.0-beta.28

Clock

Clock.clockWithconsteffect/Clock.ts:141
<A, E, R>(f: (clock: Clock) => Effect<A, E, R>): Effect<A, E, R>

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
  })
)
Source effect/Clock.ts:1411 lines
export const clockWith: <A, E, R>(f: (clock: Clock) => Effect<A, E, R>) => Effect<A, E, R> = effect.clockWith