Improve this Doc View Source $flushPendingTasks
- service in module ngMock
Overview
Flushes all currently pending tasks and executes the corresponding callbacks.
Optionally, you can also pass a delay
argument to only flush tasks that are scheduled to be executed within delay
milliseconds. Currently, delay
only applies to timeouts, since all other tasks have a delay of 0 (i.e. they are scheduled to be executed as soon as possible, but still asynchronously).
If no delay is specified, it uses a delay such that all currently pending tasks are flushed.
The types of tasks that are flushed include:
- Pending timeouts (via
$timeout
). - Pending tasks scheduled via $applyAsync.
- Pending tasks scheduled via $evalAsync. These include tasks scheduled via
$evalAsync()
indirectly (such as$q
promises).
Periodic tasks scheduled via
$interval
use a different queue and are not flushed by $flushPendingTasks()
. Use $interval.flush(millis) instead. Usage
$flushPendingTasks([delay]);
Arguments
Param | Type | Details |
---|---|---|
delay (optional) | number | The number of milliseconds to flush. |
© 2010–2018 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://code.angularjs.org/1.7.8/docs/api/ngMock/service/$flushPendingTasks