Skip to content

Commit

Permalink
Factor to treeshake better
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Sep 15, 2017
1 parent 00bc76e commit e91b6a7
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions lib/utils/async.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,31 @@
after(delay) {
return {
run(fn) { return setTimeout(fn, delay); },
cancel: window.clearTimeout.bind(window)
cancel(handle) {
window.clearTimeout(handle);
}
};
},
/**
* Enqueues a function called in the next task.
*
* @memberof Polymer.Async.timeOut
* @param {Function} fn Callback to run
* @param {number} delay Delay in milliseconds
* @return {number} Handle used for canceling task
*/
run: window.setTimeout.bind(window),
run(fn, delay) {
return window.setTimeout(fn, delay);
},
/**
* Cancels a previously enqueued `timeOut` callback.
*
* @memberof Polymer.Async.timeOut
* @param {number} handle Handle returned from `run` of callback to cancel
*/
cancel: window.clearTimeout.bind(window)
cancel(handle) {
window.clearTimeout(handle);
}
},

/**
Expand All @@ -108,14 +115,18 @@
* @param {Function} fn Callback to run
* @return {number} Handle used for canceling task
*/
run: window.requestAnimationFrame.bind(window),
run(fn) {
return window.requestAnimationFrame(fn);
},
/**
* Cancels a previously enqueued `animationFrame` callback.
*
* @memberof Polymer.Async.timeOut
* @param {number} handle Handle returned from `run` of callback to cancel
*/
cancel: window.cancelAnimationFrame.bind(window)
cancel(handle) {
window.cancelAnimationFrame(handle);
}
},

/**
Expand Down

0 comments on commit e91b6a7

Please sign in to comment.