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

Clock overview

Added in v2.0.0


Table of contents


constructors

clockWith

Signature

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

Added in v2.0.0

currentTimeMillis

Signature

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

Added in v2.0.0

currentTimeNanos

Signature

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

Added in v2.0.0

make

Signature

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

Added in v2.0.0

sleep

Signature

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

Added in v2.0.0

context

Clock

Signature

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

Added in v2.0.0

models

CancelToken (type alias)

Signature

export type CancelToken = () => boolean

Added in 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>
}

Added in 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
}

Added in v2.0.0

Task (type alias)

Signature

export type Task = () => void

Added in v2.0.0

symbols

ClockTypeId

Signature

export declare const ClockTypeId: typeof ClockTypeId

Added in v2.0.0

ClockTypeId (type alias)

Signature

export type ClockTypeId = typeof ClockTypeId

Added in v2.0.0