LuCI.request. poll

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

Methods

active() → {boolean}

Alias for LuCI.poll.active().

Returns:
Type: 
boolean

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:
NameTypeAttributesDescription
intervalnumber

The poll interval in seconds.

urlstring

The URL to request on each poll.

optionsLuCI.request.RequestOptions<optional>

Additional options to configure the request.

callbackLuCI.request.poll.callbackFn<optional>

Callback function to invoke for each HTTP reply.

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:
NameTypeDescription
entryfunction

The poll function returned by add().

Returns:

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

Type: 
boolean

start() → {boolean}

Alias for LuCI.poll.start().

Returns:
Type: 
boolean

stop() → {boolean}

Alias for LuCI.poll.stop().

Returns:
Type: 
boolean

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:
NameTypeDescription
resLuCI.response

The HTTP response object.

data*

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

durationnumber

The total duration of the request in milliseconds.