Polled<S, K, V>
An external resource that is refreshed at some polling interval.
Type Parameters
Type Parameter | Description |
---|---|
S extends Json | Type of data received from external resource. |
K extends Json | Type of keys. |
V extends Json | Type of values. |
Implements
Constructors
new Polled()
new Polled<S, K, V>(
url,
duration,
conv,
encodeParams,
options?): Polled<S, K, V>
Construct a Polled
external resource.
The URL of the external resource is formed by appending the given base url
and the result of encodeParams(params)
where params
are the parameters provided when instantiating the resource.
Note that the result of encodeParams
contains the ?
separator, but it need not be at the beginning of the returned string, so some parameters can be used in part of the URL preceding the ?
.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
url | string | undefined | HTTP endpoint of external resource to poll. |
duration | number | undefined | Refresh interval, in milliseconds. |
conv | (data ) => Entry <K , V >[] | undefined | Function to convert data of type S received from external resource to key -value entries. |
encodeParams | (params ) => string | defaultParamEncoder | Function to use to encode params of type Json for external resource request. |
options ? | { headers : {}; timeout : number ; } | undefined | Optional parameters. |
options.headers ? | {} | undefined | Additional headers to add to request. |
options.timeout ? | number | undefined | Timeout for request, in milliseconds. Defaults to 1000ms. |
Returns
Polled
<S
, K
, V
>
Methods
close()
close(instance): void
Parameters
Parameter | Type |
---|---|
instance | string |
Returns
void
Implementation of
open()
open(
instance,
params,
callbacks): void
Parameters
Parameter | Type |
---|---|
instance | string |
params | Json |
callbacks | { error : (error ) => void ; loading : () => void ; update : (updates , isInit ) => void ; } |
callbacks.error | (error ) => void |
callbacks.loading | () => void |
callbacks.update | (updates , isInit ) => void |
Returns
void