LuCI. poll

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

Methods

active() → {boolean}

Test whether the polling loop is running.

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 implicitly started.

Parameters:
NameTypeDescription
fnfunction

The function to invoke on each poll interval.

intervalnumber

The poll interval in seconds.

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

Parameters:
NameTypeDescription
fnfunction

The function to remove.

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.

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.

Returns:

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

Type: 
boolean