# 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.

#### new LuCI.request.poll()

luci.js, line 930

### Methods

#### active()

luci.js, line 1034

  Alias for `LuCI.poll.active()`.

#### add(interval, url, options, callback){function}

luci.js, line 973

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

  Name | Type | 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.

  ##### Throws:

  Throws `TypeError` when an invalid interval was passed.

  Type
    TypeError

  ##### Returns:

  Type | Description
  --- | ---
  function | Returns the internally created poll function.

#### remove(entry){boolean}

luci.js, line 1010

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

  Name | Type | Description
  --- | --- | ---
  `entry` | function | The poll function returned by `add()`.

  ##### Returns:

  Type | Description
  --- | ---
  boolean | Returns `true` if any function has been removed, else `false`.

#### start()

luci.js, line 1018

  Alias for `LuCI.poll.start()`.

#### stop()

luci.js, line 1026

  Alias for `LuCI.poll.stop()`.

### Type Definitions

#### callbackFn(res, data, duration)

luci.js, line 931

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

  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.