From 00927bae44af9ad99c67f1f86f1bdf19855aaff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Meier?= Date: Fri, 15 Mar 2024 22:24:27 +0100 Subject: [PATCH] Publish v0.3.0-alpha.9 fix sync/Latest --- package.json | 2 +- src/sync/Latest.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) 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; }, }; }