Hyperlinkv0.8.0-beta.28

Effect

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

Retrieves the Clock service from the context and provides it to the specified effectful function.

Example (Accessing the Clock service)

import { Console, Effect } from "effect"

const program = Effect.clockWith((clock) =>
  clock.currentTimeMillis.pipe(
    Effect.map((currentTime) => `Current time is: ${currentTime}`),
    Effect.tap(Console.log)
  )
)

Effect.runFork(program)
// Example Output:
// Current time is: 1735484929744
clock
export const clockWith: <A, E, R>(
  f: (clock: Clock) => Effect<A, E, R>
) => Effect<A, E, R> = internal.clockWith
Referenced by 3 symbols