diff --git a/package.json b/package.json index 8a82f1c..e13427d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fire-lib-js", - "version": "0.3.0-alpha.8", + "version": "0.3.0-alpha.9", "author": "Sören Meier ", "type": "module", "scripts": { diff --git a/src/sync/Latest.ts b/src/sync/Latest.ts index 31743b4..ca25fa0 100644 --- a/src/sync/Latest.ts +++ b/src/sync/Latest.ts @@ -34,6 +34,10 @@ 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; @@ -41,10 +45,7 @@ export default class Latest { this.listeners.forEach(resolve => resolve(true)); this.listeners = []; - // queued as a microtask latest(false); - - this.running = false; }, }; }