Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sync writes to multiMerge() in WebStorage. Fix caching when multiMerge() runs. #122

Merged
merged 9 commits into from
Mar 18, 2022
Prev Previous commit
Next Next commit
add some comments to the sync queue
  • Loading branch information
marcaaron committed Mar 10, 2022
commit 1ac6096bbc2d41fb25b6c885a189e4b789e1d4b7
16 changes: 16 additions & 0 deletions lib/SyncQueue.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
/**
* Synchronous queue that can be used to ensure promise based tasks are run in sequence.
* Pass to the constructor a function that returns a promise to run the task then add data.
*
* @example
*
* const queue = new SyncQueue(({key, val}) => {
* return someAsyncProcess(key, val);
* });
*
* queue.push({key: 1, val: '1'});
* queue.push({key: 2, val: '2'});
*/
export default class SyncQueue {
/**
* @param {Function} run - must return a promise
*/
constructor(run) {
this.queue = [];
this.isProcessing = false;
Expand Down