View source Improve this doc

$interval

service in module ngMock

Description

Mock implementation of the $interval service.

Use $interval.flush(millis) to move forward by millis milliseconds and trigger any functions scheduled to run in that time.

Usage

  1. $interval(fn, delay[, count][, invokeApply]);

Parameters

ParamTypeDetails
fnfunction() A function that should be called repeatedly.
delaynumber Number of milliseconds between each function call.
count (optional) number Number of times to repeat. If not set, or 0, will repeat indefinitely. (default: 0)
invokeApply (optional) boolean If set to false skips model dirty checking, otherwise will invoke fn within the $apply block. (default: true)

Returns

promise A promise which will be notified on each iteration.

Methods

  • flush(millis)

Runs interval tasks scheduled to be run in the next millis milliseconds.

Parameters

ParamTypeDetailsmillis (optional) number

maximum timeout amount to flush up until.

Returns

number

The amount of time moved forward.