Ember.run.schedule()

schedule (queue, target, method, arguments*) *public

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

Adds the passed target/method and any optional arguments to the named queue to be executed at the end of the RunLoop. If you have not already started a RunLoop when calling this method one will be started for you automatically.

At the end of a RunLoop, any methods scheduled in this way will be invoked. Methods will be invoked in an order matching the named queues defined in the run.queues property.

run.schedule('sync', this, function() {
  // this will be executed in the first RunLoop queue, when bindings are synced
  console.log('scheduled on sync queue');
});

run.schedule('actions', this, function() {
  // this will be executed in the 'actions' queue, after bindings have synced.
  console.log('scheduled on actions queue');
});

// Note the functions will be run in order based on the run queues order.
// Output would be:
//   scheduled on sync queue
//   scheduled on actions queue

Parameters:

queue String
The name of the queue to schedule against. Default queues are 'sync' and 'actions'
target [Object]
target object to use as the context when invoking a method.
method String|Function
The method to invoke. If you pass a string it will be resolved on the target object at the time the scheduled item is invoked allowing you to change the target function.
arguments* [Object]
Optional arguments to be passed to the queued method.

Returns:

*
Timer information for use in cancelling, see `run.cancel`.
doc_EmberJs
2016-11-30 16:51:41
Comments
Leave a Comment

Please login to continue.