querysub 0.174.0 → 0.175.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.174.0",
3
+ "version": "0.175.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -24,7 +24,7 @@
24
24
  "node-forge": "https://github.com/sliftist/forge#e618181b469b07bdc70b968b0391beb8ef5fecd6",
25
25
  "pako": "^2.1.0",
26
26
  "preact": "^10.11.3",
27
- "socket-function": "^0.121.0",
27
+ "socket-function": "^0.122.0",
28
28
  "terser": "^5.31.0",
29
29
  "typesafecss": "^0.15.0",
30
30
  "yaml": "^2.5.0",
@@ -218,8 +218,8 @@ export type SyncWatcher = {
218
218
 
219
219
  dispose: () => void;
220
220
  disposed?: boolean;
221
- // Reset every time the function is committed, so that inner callbacks can know when the dispose
222
- // happens, without having to dedupe their callback function.
221
+ // Reset every time the function is run, so this can be subscribed to every run, but will
222
+ // only be called once the final commit.
223
223
  onInnerDisposed: (() => void)[];
224
224
  // Runs after any trigger happens (usually multiple triggers are required for a commit)
225
225
  onAfterTriggered: (() => void)[];
@@ -1082,6 +1082,8 @@ export class PathValueProxyWatcher {
1082
1082
 
1083
1083
  watcher.pendingAccesses.clear();
1084
1084
  watcher.pendingEpochAccesses.clear();
1085
+ // IMPORTANT! Reset onInnerDisposed, so onCommitFinished doesn't result in a callback
1086
+ // per time we wan the watcher!
1085
1087
  watcher.onInnerDisposed = [];
1086
1088
 
1087
1089
  // NOTE: If runAtTime is undefined, the writeTime will be undefined, causing us to read the latest data.
@@ -388,6 +388,13 @@ export class Querysub {
388
388
  });
389
389
  }
390
390
 
391
+ public static afterAllRendersFinished(callback: () => void) {
392
+ // onCommitFinished prevents duplicates, as well as only running when we are actually done
393
+ Querysub.onCommitFinished(() => {
394
+ void clientWatcher.waitForTriggerFinished()?.finally(callback);
395
+ });
396
+ }
397
+
391
398
  /** Solely for use to prevent local writes from occuring before predictions. We MIGHT make this a framework thing,
392
399
  * or just not bother with it (as after a prediction is run once the code will be loaded allowing it to always
393
400
  * run before the next frame).