Methods
active() → {boolean}
Test whether the polling loop is running.
- Returns
trueif polling is active, elsefalse.
- Type:
- boolean
add(fn, interval) → {boolean}
Add a new operation to the polling loop. If the polling loop is not already started at this point, it will be implicitly started.
| Name | Type | Description |
|---|---|---|
fn | function | The function to invoke on each poll interval. |
interval | number | The poll interval in seconds. |
Throws
TypeErrorwhen an invalid interval was passed.- Type
- TypeError
Returns true if the function has been added or false if it already is registered.
- Type:
- boolean
remove(fn) → {boolean}
Remove an operation from the polling loop. If no further operations are registered, the polling loop is implicitly stopped.
| Name | Type | Description |
|---|---|---|
fn | function | The function to remove. |
Throws
TypeErrorwhen the given argument isn't a function.- Type
- TypeError
Returns true if the function has been removed or false if it wasn't found.
- Type:
- boolean
start() → {boolean}
(Re)start the polling loop. Dispatches a custom poll-start event to the document object upon successful start.
Returns true if polling has been started (or if no functions where registered) or false when the polling loop already runs.
- Type:
- boolean
stop() → {boolean}
Stop the polling loop. Dispatches a custom poll-stop event to the document object upon successful stop.
Returns true if polling has been stopped or false if it didn't run to begin with.
- Type:
- boolean