Skip to content

Instantly share code, notes, and snippets.

@hendrikswan
Last active June 15, 2017 07:21
Show Gist options
  • Save hendrikswan/d6a29c39f00a4b3e86d48a03d185ac2c to your computer and use it in GitHub Desktop.
Save hendrikswan/d6a29c39f00a4b3e86d48a03d185ac2c to your computer and use it in GitHub Desktop.
const pendingItems = new Rx.Subject();
pendingItems.subscribe((item) => {
api.syncEvent(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');
pendingItems.next(item);
});
});
function syncMouseEvent(event) {
pendingItems.next({
x: event.clientX,
y: event.clientY
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment