Function

later (target, method, args*, wait) * public

Module: @ember/runloop
import { later } from '@ember/runloop';
target
Object
target of method to invoke
method
Function|String
The method to invoke. If you pass a string it will be resolved on the target at the time the method is invoked.
args*
Object
Optional arguments to pass to the timeout.
wait
Number
Number of milliseconds to wait.
returns
*
Timer information for use in canceling, see `cancel`.

Invokes the passed target/method and optional arguments after a specified period of time. The last parameter of this method must always be a number of milliseconds.

You should use this method whenever you need to run some action after a period of time instead of using setTimeout(). This method will ensure that items that expire during the same script execution cycle all execute together, which is often more efficient than using a real setTimeout.

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

later(myContext, function() {
  // code here will execute within a RunLoop in about 500ms with this == myContext
}, 500);

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