@@ -17,31 +17,43 @@ newtype TimeoutId = TimeoutId Int
1717derive instance eqTimeoutId :: Eq TimeoutId
1818derive instance ordTimeoutId :: Ord TimeoutId
1919
20+ foreign import setTimeoutImpl :: Int -> Effect Unit -> Effect TimeoutId
21+
2022-- | Runs an effectful function after the specified delay in milliseconds. The
2123-- | returned `TimeoutId` can be used to cancel the timer before it completes.
2224-- |
2325-- | The timeout delay value is capped at 4ms by the JS API, any value less than
2426-- | this will be clamped.
25- foreign import setTimeout :: Int -> Effect Unit -> Effect TimeoutId
27+ setTimeout :: Int -> Effect Unit -> Effect TimeoutId
28+ setTimeout = setTimeoutImpl
29+
30+ foreign import clearTimeoutImpl :: TimeoutId -> Effect Unit
2631
2732-- | Cancels a timeout. If the timeout has already been cancelled or has already
2833-- | elapsed this will have no effect.
29- foreign import clearTimeout :: TimeoutId -> Effect Unit
34+ clearTimeout :: TimeoutId -> Effect Unit
35+ clearTimeout = clearTimeoutImpl
3036
3137-- | The ID of a timer started with `setInterval`.
3238newtype IntervalId = IntervalId Int
3339
3440derive instance eqIntervalId :: Eq IntervalId
3541derive instance ordIntervalId :: Ord IntervalId
3642
43+ foreign import setIntervalImpl :: Int -> Effect Unit -> Effect IntervalId
44+
3745-- | Runs an effectful function after on a set interval with the specified delay
3846-- | in milliseconds between iterations. The returned `IntervalId` can be used
3947-- | to cancel the timer and prevent the interval from running any further.
4048-- |
4149-- | The interval delay value is capped at 4ms by the JS API, any value less
4250-- | than this will be clamped.
43- foreign import setInterval :: Int -> Effect Unit -> Effect IntervalId
51+ setInterval :: Int -> Effect Unit -> Effect IntervalId
52+ setInterval = setIntervalImpl
53+
54+ foreign import clearIntervalImpl :: IntervalId -> Effect Unit
4455
4556-- | Cancels an interval timer. If the interval has already been cancelled this
4657-- | will have no effect.
47- foreign import clearInterval :: IntervalId -> Effect Unit
58+ clearInterval :: IntervalId -> Effect Unit
59+ clearInterval = clearIntervalImpl
0 commit comments