Skip to main content Link Search Menu Expand Document (external link)

Clock.ts overview

Since v2.0.0


Exports Grouped by Category


constructors

clockWith

Signature

declare const clockWith: <A, E, R>(f: (clock: Clock) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>

Source

Since v2.0.0

currentTimeMillis

Signature

declare const currentTimeMillis: Effect.Effect<number, never, never>

Source

Since v2.0.0

currentTimeNanos

Signature

declare const currentTimeNanos: Effect.Effect<bigint, never, never>

Source

Since v2.0.0

make

Signature

declare const make: (_: void) => Clock

Source

Since v2.0.0

sleep

Signature

declare const sleep: (duration: Duration.DurationInput) => Effect.Effect<void>

Source

Since v2.0.0

context

Clock

Signature

declare const Clock: Context.Tag<Clock, Clock>

Source

Since v2.0.0

models

CancelToken (type alias)

Signature

type CancelToken = () => boolean

Source

Since v2.0.0

Clock (interface)

Represents a time-based clock which provides functionality related to time and scheduling.

Signature

export interface Clock {
  readonly [ClockTypeId]: ClockTypeId
  /**
   * Unsafely returns the current time in milliseconds.
   */
  unsafeCurrentTimeMillis(): number
  /**
   * Returns the current time in milliseconds.
   */
  readonly currentTimeMillis: Effect.Effect<number>
  /**
   * Unsafely returns the current time in nanoseconds.
   */
  unsafeCurrentTimeNanos(): bigint
  /**
   * Returns the current time in nanoseconds.
   */
  readonly currentTimeNanos: Effect.Effect<bigint>
  /**
   * Asynchronously sleeps for the specified duration.
   */
  sleep(duration: Duration.Duration): Effect.Effect<void>
}

Source

Since v2.0.0

ClockScheduler (interface)

Signature

export interface ClockScheduler {
  /**
   * Unsafely schedules the specified task for the specified duration.
   */
  unsafeSchedule(task: Task, duration: Duration.Duration): CancelToken
}

Source

Since v2.0.0

Task (type alias)

Signature

type Task = () => void

Source

Since v2.0.0

symbols

ClockTypeId

Signature

declare const ClockTypeId: unique symbol

Source

Since v2.0.0

ClockTypeId (type alias)

Signature

type ClockTypeId = typeof ClockTypeId

Source

Since v2.0.0