schedule (queue, target, method, arguments*) *
public
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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`.
Please login to continue.