Class: Poll

LuCI.Poll

The Poll class allows registering and unregistering poll actions, as well as starting, stopping and querying the state of the polling loop.

Source:

Methods

active() → {boolean}

Test whether the polling loop is running.

Source:
Returns:
  • Returns true if polling is active, else false.
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 implicitely started.

Parameters:
Name Type Description
fn function

The function to invoke on each poll interval.

interval number

The poll interval in seconds.

Source:
Throws:

Throws TypeError when an invalid interval was passed.

Type
TypeError
Returns:

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 operatons are registered, the polling loop is implicitely stopped.

Parameters:
Name Type Description
fn function

The function to remove.

Source:
Throws:

Throws TypeError when the given argument isn't a function.

Type
TypeError
Returns:

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.

Source:
Returns:

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.

Source:
Returns:

Returns true if polling has been stopped or false if it din't run to begin with.

Type
boolean