You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 23, 2019. It is now read-only.
On the assumption of polling always happens on a defined function at an interval, a callback consumed for polling will have no received arguments. But this could not be the case for certain use cases where polling could be done with different value of offsets, say, fire requests for the next 100 items then the next 200 items.
Proposed implementation with feature to pass arguments from conditionCallback
constpoller=newPollingObserver((data/**, list, observer */)=>{const{ totalCount, status, items }=data;constdone='complete'===status||items.length>99;/** * `done` {@type boolean} If true, the polling should stop. * `value` {@type any} Arguments to be passed to polling callback on each execution. */return{ done,value: { totalCount }};});constpollingFn=async(args)=>{const{ totalCount }=args;// Destructure `totalCount` sent from `conditionCallback`constr=awaitfetch(`https://example.com/some-api?from=${totalCount||0}`);returnr.json();};constopts={interval: 2e3,timeout: 30e3};poller.observe(pollingFn,opts);