Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
Publish v0.3.0-alpha.9 fix sync/Latest
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenmeier committed Mar 15, 2024
1 parent 8a8bd40 commit 00927ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fire-lib-js",
"version": "0.3.0-alpha.8",
"version": "0.3.0-alpha.9",
"author": "Sören Meier <[email protected]>",
"type": "module",
"scripts": {
Expand Down
7 changes: 4 additions & 3 deletions src/sync/Latest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,18 @@ export default class Latest {
if (canceled)
throw new Error('calling done on a cancelled function');

// since all promises are delayed to the next microtask we can set
// running before
this.running = false;

// notify the latest
const latest = this.listeners.pop();
if (!latest) return;

this.listeners.forEach(resolve => resolve(true));
this.listeners = [];

// queued as a microtask
latest(false);

this.running = false;
},
};
}
Expand Down

0 comments on commit 00927ba

Please sign in to comment.