Class: poll

LuCI.Request.poll

The Request.poll class provides some convience wrappers around LuCI.Poll mainly to simplify registering repeating HTTP request calls as polling functions.

Source:

Methods

active()

Alias for LuCI.Poll.active().

Source:

add(interval, url, optionsopt, callbackopt) → {function}

Register a repeating HTTP request with an optional callback to invoke whenever a response for the request is received.

Parameters:
Name Type Attributes Description
interval number

The poll interval in seconds.

url string

The URL to request on each poll.

options LuCI.Request.RequestOptions <optional>

Additional options to configure the request.

callback LuCI.Request.poll~callbackFn <optional>

Callback function to invoke for each HTTP reply.

Source:
Throws:

Throws TypeError when an invalid interval was passed.

Type
TypeError
Returns:

Returns the internally created poll function.

Type
function

remove(entry) → {boolean}

Remove a polling request that has been previously added using add(). This function is essentially a wrapper around LuCI.Poll.remove().

Parameters:
Name Type Description
entry function

The poll function returned by add().

Source:
Returns:

Returns true if any function has been removed, else false.

Type
boolean

start()

Alias for LuCI.Poll.start().

Source:

stop()

Alias for LuCI.Poll.stop().

Source:

Type Definitions

callbackFn(res, data, duration)

The callback function is invoked whenever an HTTP reply to a polled request is received or when the polled request timed out.

Parameters:
Name Type Description
res LuCI.Response

The HTTP response object.

data *

The response JSON if the response could be parsed as such, else null.

duration number

The total duration of the request in milliseconds.

Source: