Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Effect/Timer.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
/* no-redeclare global exports */
export function setTimeout(ms) {
export function setTimeout_(ms) {
return function (fn) {
return function () {
return setTimeout(fn, ms);
};
};
}

export function clearTimeout(id) {
export function clearTimeout_(id) {
return function () {
clearTimeout(id);
};
}

export function setInterval(ms) {
export function setInterval_(ms) {
return function (fn) {
return function () {
return setInterval(fn, ms);
};
};
}

export function clearInterval(id) {
export function clearInterval_(id) {
return function () {
clearInterval(id);
};
Expand Down
17 changes: 12 additions & 5 deletions src/Effect/Timer.purs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ derive instance ordTimeoutId :: Ord TimeoutId
-- |
-- | The timeout delay value is capped at 4ms by the JS API, any value less than
-- | this will be clamped.
foreign import setTimeout :: Int -> Effect Unit -> Effect TimeoutId
setTimeout :: Int -> Effect Unit -> Effect TimeoutId
setTimeout = setTimeout_
foreign import setTimeout_ :: Int -> Effect Unit -> Effect TimeoutId

-- | Cancels a timeout. If the timeout has already been cancelled or has already
-- | elapsed this will have no effect.
foreign import clearTimeout :: TimeoutId -> Effect Unit

clearTimeout :: TimeoutId -> Effect Unit
clearTimeout = clearTimeout_
foreign import clearTimeout_ :: TimeoutId -> Effect Unit
-- | The ID of a timer started with `setInterval`.
newtype IntervalId = IntervalId Int

Expand All @@ -40,8 +43,12 @@ derive instance ordIntervalId :: Ord IntervalId
-- |
-- | The interval delay value is capped at 4ms by the JS API, any value less
-- | than this will be clamped.
foreign import setInterval :: Int -> Effect Unit -> Effect IntervalId
setInterval :: Int -> Effect Unit -> Effect IntervalId
setInterval = setInterval_
foreign import setInterval_ :: Int -> Effect Unit -> Effect IntervalId

-- | Cancels an interval timer. If the interval has already been cancelled this
-- | will have no effect.
foreign import clearInterval :: IntervalId -> Effect Unit
clearInterval :: IntervalId -> Effect Unit
clearInterval = clearInterval_
foreign import clearInterval_ :: IntervalId -> Effect Unit