Function

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

Module: @ember/runloop
import { schedule } from '@ember/runloop';
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 canceling, see `run.cancel`.

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.

import { schedule } from '@ember/runloop';

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

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

© 2020 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember/2.18/functions/@ember%2Frunloop/schedule