Skip to content

Instantly share code, notes, and snippets.

@hendrikswan
Last active June 15, 2017 09:14
Show Gist options
  • Select an option

  • Save hendrikswan/331d31bbd12ba7a55e74f78391fdc5d4 to your computer and use it in GitHub Desktop.

Select an option

Save hendrikswan/331d31bbd12ba7a55e74f78391fdc5d4 to your computer and use it in GitHub Desktop.
pendingItems
.map(item => Rx.Observable.of(item).delay(item.sync.counter > 0 ? delayBetweenRetries : 0))
.mergeAll()
.subscribe((itemWithMetaData) => {
api.syncEvent(itemWithMetaData.item)
.then((result) => {
console.log('successfully synced a mouse event');
})
.catch((reason) => {
console.error('got an error while trying to sync an event, going to try again');
queue(itemWithMetaData);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment