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>
Since v2.0.0
currentTimeMillis
Signature
declare const currentTimeMillis: Effect.Effect<number, never, never>
Since v2.0.0
currentTimeNanos
Signature
declare const currentTimeNanos: Effect.Effect<bigint, never, never>
Since v2.0.0
make
Signature
declare const make: (_: void) => Clock
Since v2.0.0
sleep
Signature
declare const sleep: (duration: Duration.DurationInput) => Effect.Effect<void>
Since v2.0.0
context
Clock
Signature
declare const Clock: Context.Tag<Clock, Clock>
Since v2.0.0
models
CancelToken (type alias)
Signature
type CancelToken = () => boolean
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>
}
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
}
Since v2.0.0
Task (type alias)
Signature
type Task = () => void
Since v2.0.0
symbols
ClockTypeId
Signature
declare const ClockTypeId: unique symbol
Since v2.0.0
ClockTypeId (type alias)
Signature
type ClockTypeId = typeof ClockTypeId
Since v2.0.0