-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
When making multiple change on a syncable object, multiple call to send are made and only the first callback of send will be called.
One way to work around this problem is to ensure only one call to change is made by Task of the EventLoop (by using setImmadiate for example). Or store the promise return by send to call the next send after the promise resolve and ignore all other send while a send is queued.
const s = syncable({
a: false,
b: false
});
s.subscribe((value, meta, hasUnsentChanges) => {
console.log(value, meta, hasUnsentChanges);
if (hasUnsentChanges) {
s.send((changes) => {
console.log(changes);
return Promise.resolve()
})
}
});
s.change(new JSONPatch().add('/a', true));
s.change(new JSONPatch().add('/b', true));
s.change(new JSONPatch().add('/a', false));Metadata
Metadata
Assignees
Labels
No labels