The basic idea is that you can pass a poll value in the params when using the get method ( https://github.com/resin-io/pinejs-client-js/blob/master/core.coffee#L391 ) that will cause the request to be run every X seconds. If the poll value is present and is a number, the number will represent the poll interval in ms, otherwise, a sensible default will be used.
If the poll value is present, the get method will return an event emitter that will emit the following events:
data the response payload after a successful request
error the error should a request fail
The returned emitter should have the following methods:
pause pause poll execution
resume resume poll execution if the poll is paused
destroy destroys the poll and removes the interval
An example of use with the sdk could look like this:
Connects to https://github.com/resin-io/resin-ui/issues/1285
The basic idea is that you can pass a
poll
value in the params when using theget
method ( https://github.com/resin-io/pinejs-client-js/blob/master/core.coffee#L391 ) that will cause the request to be run every X seconds. If thepoll
value is present and is a number, the number will represent the poll interval in ms, otherwise, a sensible default will be used.If the
poll
value is present, theget
method will return an event emitter that will emit the following events:data
the response payload after a successful requesterror
the error should a request failThe returned emitter should have the following methods:
pause
pause poll executionresume
resume poll execution if the poll is pauseddestroy
destroys the poll and removes the intervalAn example of use with the sdk could look like this:
In the future, the polling could be replaced with socket events.