Function
later (target, method, args*, wait) * public
Module:
@ember/runloop
Defined in packages/@ember/runloop/index.ts:442
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.
1 2 3 4 5 |
import { later } from '@ember/runloop';
later(myContext, function() {
// code here will execute within a RunLoop in about 500ms with this == myContext
}, 500); |