diff --git a/src/js/state/Node.ts b/src/js/state/Node.ts index a4c8eb71f..d9d269947 100644 --- a/src/js/state/Node.ts +++ b/src/js/state/Node.ts @@ -226,14 +226,13 @@ export default class Node { /** * Same as on(), but will unsubscribe after the first callback * @param callback - * @param unsubscribe */ - once(callback?: Callback, returnIfUndefined = false, unsubscribe?: Unsubscribe): Promise { + once(callback?: Callback, returnIfUndefined = false): Promise { return new Promise((resolve) => { + let resolved = false; const cb = (value, updatedAt, path, unsub) => { - if (unsubscribe) { - unsubscribe(); - } + if (resolved) return; + resolved = true; resolve(value); callback?.(value, updatedAt, path, () => {}); unsub();