Skip to main content

Polled<S, K, V>

An external resource that is refreshed at some polling interval.

Type Parameters

Type ParameterDescription
S extends JsonType of data received from external resource.
K extends JsonType of keys.
V extends JsonType 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

ParameterTypeDefault valueDescription
urlstringundefinedHTTP endpoint of external resource to poll.
durationnumberundefinedRefresh interval, in milliseconds.
conv(data) => Entry<K, V>[]undefinedFunction to convert data of type S received from external resource to key-value entries.
encodeParams(params) => stringdefaultParamEncoderFunction to use to encode params of type Json for external resource request.
options?{ headers: {}; timeout: number; }undefinedOptional parameters.
options.headers?{}undefinedAdditional headers to add to request.
options.timeout?numberundefinedTimeout for request, in milliseconds. Defaults to 1000ms.

Returns

Polled<S, K, V>

Methods

close()

close(instance): void

Parameters

ParameterType
instancestring

Returns

void

Implementation of

ExternalResource.close


open()

open(
instance,
params,
callbacks): void

Parameters

ParameterType
instancestring
paramsJson
callbacks{ error: (error) => void; loading: () => void; update: (updates, isInit) => void; }
callbacks.error(error) => void
callbacks.loading() => void
callbacks.update(updates, isInit) => void

Returns

void

Implementation of

ExternalResource.open