Module

Effect.Timer

#TimeoutId

newtype TimeoutId

The ID of a timer started with setTimeout.

Instances

#setTimeout

setTimeout :: Int -> Effect Unit -> Effect TimeoutId

Runs an effectful function after the specified delay in milliseconds. The returned TimeoutId can be used to cancel the timer before it completes.

The timeout delay value is capped at 4ms by the JS API, any value less than this will be clamped.

#clearTimeout

clearTimeout :: TimeoutId -> Effect Unit

Cancels a timeout. If the timeout has already been cancelled or has already elapsed this will have no effect.

#IntervalId

newtype IntervalId

The ID of a timer started with setInterval.

Instances

#setInterval

setInterval :: Int -> Effect Unit -> Effect IntervalId

Runs an effectful function after on a set interval with the specified delay in milliseconds between iterations. The returned IntervalId can be used to cancel the timer and prevent the interval from running any further.

The interval delay value is capped at 4ms by the JS API, any value less than this will be clamped.

#clearInterval

clearInterval :: IntervalId -> Effect Unit

Cancels an interval timer. If the interval has already been cancelled this will have no effect.

Modules