Module

Control.Monad.Eff.Timer

Package
purescript-js-timers
Repository
purescript-contrib/purescript-js-timers

#TIMER Source

data TIMER :: Effect

The effect for the usage of a JavaScript timer.

#TimeoutId Source

newtype TimeoutId

The ID of a timer started with setTimeout.

Instances

#setTimeout Source

setTimeout :: forall eff. Int -> Eff (timer :: TIMER | eff) Unit -> Eff (timer :: TIMER | eff) 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 Source

clearTimeout :: forall eff. TimeoutId -> Eff (timer :: TIMER | eff) Unit

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

#IntervalId Source

newtype IntervalId

The ID of a timer started with setInterval.

Instances

#setInterval Source

setInterval :: forall eff. Int -> Eff (timer :: TIMER | eff) Unit -> Eff (timer :: TIMER | eff) 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 Source

clearInterval :: forall eff. IntervalId -> Eff (timer :: TIMER | eff) Unit

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