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.

new LuCI.poll()

Methods

active(){boolean}

Test whether the polling loop is running.

Returns:
Type Description
boolean
  • Returns true if polling is active, else false.

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.

Name Type Description
fn function

The function to invoke on each poll interval.

interval number

The poll interval in seconds.

Throws:

Throws TypeError when an invalid interval was passed.

Type
TypeError
Returns:
Type Description
boolean Returns true if the function has been added or false if it already is registered.

remove(fn){boolean}

Remove an operation from the polling loop. If no further operatons are registered, the polling loop is implicitely stopped.

Name Type Description
fn function

The function to remove.

Throws:

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

Type
TypeError
Returns:
Type Description
boolean Returns true if the function has been removed or false if it wasn't found.

start(){boolean}

(Re)start the polling loop. Dispatches a custom poll-start event to the document object upon successful start.

Returns:
Type Description
boolean Returns true if polling has been started (or if no functions where registered) or false when the polling loop already runs.

stop(){boolean}

Stop the polling loop. Dispatches a custom poll-stop event to the document object upon successful stop.

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