Ember.run.cancel()

cancel (timer) Booleanpublic

Defined in packages/ember-metal/lib/run_loop.js:493

Cancels a scheduled item. Must be a value returned by run.later(), run.once(), run.scheduleOnce(), run.next(), run.debounce(), or run.throttle().

let runNext = run.next(myContext, function() {
  // will not be executed
});

run.cancel(runNext);

let runLater = run.later(myContext, function() {
  // will not be executed
}, 500);

run.cancel(runLater);

let runScheduleOnce = run.scheduleOnce('afterRender', myContext, function() {
  // will not be executed
});

run.cancel(runScheduleOnce);

let runOnce = run.once(myContext, function() {
  // will not be executed
});

run.cancel(runOnce);

let throttle = run.throttle(myContext, function() {
  // will not be executed
}, 1, false);

run.cancel(throttle);

let debounce = run.debounce(myContext, function() {
  // will not be executed
}, 1);

run.cancel(debounce);

let debounceImmediate = run.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 cancelled
run.cancel(debounceImmediate);

Parameters:

timer Object
Timer object to cancel

Returns:

Boolean
true if cancelled or false/undefined if it wasn't found
doc_EmberJs
2016-11-30 16:51:39
Comments
Leave a Comment

Please login to continue.