@t8/react-pending 1.0.7 → 1.0.8

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.
Files changed (2) hide show
  1. package/dist/index.js +3 -3
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ function isStore(x) {
13
13
  var Store = class {
14
14
  state;
15
15
  callbacks = [];
16
- revision = 0;
16
+ revision = -1;
17
17
  constructor(data) {
18
18
  this.state = data;
19
19
  }
@@ -32,8 +32,7 @@ var Store = class {
32
32
  let prevState = this.state;
33
33
  let nextState = update instanceof Function ? update(this.state) : update;
34
34
  this.state = nextState;
35
- if (this.revision === Number.MAX_SAFE_INTEGER) this.revision = 1;
36
- else this.revision++;
35
+ this.revision = Math.random();
37
36
  for (let callback of this.callbacks) callback(nextState, prevState);
38
37
  }
39
38
  };
@@ -61,6 +60,7 @@ function useStore(store, shouldUpdate = true) {
61
60
  return () => {
62
61
  unsubscribe();
63
62
  initedRef.current = false;
63
+ initialStoreRevision.current = store.revision;
64
64
  };
65
65
  }, [store, shouldUpdate]);
66
66
  return [state, setState];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/react-pending",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Concise async action state tracking for React apps",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -32,6 +32,6 @@
32
32
  "@types/react": "^19.1.10"
33
33
  },
34
34
  "dependencies": {
35
- "@t8/react-store": "^1.0.7"
35
+ "@t8/react-store": "^1.0.8"
36
36
  }
37
37
  }