Function
cancel (timer) Boolean public
Module: | @ember/runloop |
---|
Defined in packages/ember-metal/lib/run_loop.js:548
import { cancel } from '@ember/runloop';
- timer
- Object
- Timer object to cancel
- returns
- Boolean
- true if canceled or false/undefined if it wasn't found
Cancels a scheduled item. Must be a value returned by later()
, once()
, scheduleOnce()
, next()
, debounce()
, or throttle()
.
import { next, cancel, later, scheduleOnce, once, throttle, debounce } from '@ember/runloop'; let runNext = next(myContext, function() { // will not be executed }); cancel(runNext); let runLater = later(myContext, function() { // will not be executed }, 500); cancel(runLater); let runScheduleOnce = scheduleOnce('afterRender', myContext, function() { // will not be executed }); cancel(runScheduleOnce); let runOnce = once(myContext, function() { // will not be executed }); cancel(runOnce); let throttle = throttle(myContext, function() { // will not be executed }, 1, false); cancel(throttle); let debounce = debounce(myContext, function() { // will not be executed }, 1); cancel(debounce); let debounceImmediate = debounce(myContext, function() { // will be executed since we passed in true (immediate) }, 100, true); // the 100ms delay until this method can be called again will be canceled cancel(debounceImmediate);
© 2020 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember/2.18/functions/@ember%2Frunloop/cancel