@dvashim/store 1.4.5 → 1.4.6

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/README.md CHANGED
@@ -148,13 +148,18 @@ remaining$.isConnected // true
148
148
 
149
149
  ### `useStore(store, selector?)`
150
150
 
151
- React hook that subscribes a component to a store.
151
+ React hook that subscribes a component to any `SourceStore` — works with both `Store` and `ComputedStore`.
152
152
 
153
153
  ```tsx
154
154
  function Counter() {
155
155
  const count = useStore(count$)
156
156
  return <p>{count}</p>
157
157
  }
158
+
159
+ function Remaining() {
160
+ const remaining = useStore(remaining$)
161
+ return <p>{remaining} left</p>
162
+ }
158
163
  ```
159
164
 
160
165
  #### With a selector
@@ -1,14 +1,13 @@
1
- import type { Store } from './Store';
2
- import type { Selector } from './types';
1
+ import type { Selector, SourceStore } from './types';
3
2
  /**
4
- * Subscribes a React component to a {@link Store} and returns its current state.
3
+ * Subscribes a React component to a {@link SourceStore} and returns its current state.
5
4
  *
6
5
  * @param store - The store to subscribe to.
7
6
  * @returns The current state of the store.
8
7
  */
9
- declare function useStore<T>(store: Store<T>): T;
8
+ declare function useStore<T>(store: SourceStore<T>): T;
10
9
  /**
11
- * Subscribes a React component to a {@link Store} and returns a derived value
10
+ * Subscribes a React component to a {@link SourceStore} and returns a derived value
12
11
  * computed by the selector.
13
12
  *
14
13
  * The selector should return a referentially stable value (e.g. a primitive or
@@ -19,6 +18,6 @@ declare function useStore<T>(store: Store<T>): T;
19
18
  * @param selector - A function that derives a value from the store state.
20
19
  * @returns The value returned by the selector.
21
20
  */
22
- declare function useStore<T, U>(store: Store<T>, selector: Selector<T, U>): U;
21
+ declare function useStore<T, U>(store: SourceStore<T>, selector: Selector<T, U>): U;
23
22
  export { useStore };
24
23
  //# sourceMappingURL=useStore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useStore.d.ts","sourceRoot":"","sources":["../src/useStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC;;;;;GAKG;AACH,iBAAS,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAExC;;;;;;;;;;;GAWG;AACH,iBAAS,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAA;AA0BrE,OAAO,EAAE,QAAQ,EAAE,CAAA"}
1
+ {"version":3,"file":"useStore.d.ts","sourceRoot":"","sources":["../src/useStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAEpD;;;;;GAKG;AACH,iBAAS,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAE9C;;;;;;;;;;;GAWG;AACH,iBAAS,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAA;AA6B3E,OAAO,EAAE,QAAQ,EAAE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useStore.js","sourceRoot":"","sources":["../src/useStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AA0B5E,SAAS,QAAQ,CAAW,KAAe,EAAE,QAAyB;IACpE,MAAM,WAAW,GAAG,MAAM,CAAkB,SAAS,CAAC,CAAA;IACtD,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAA;IAE9B,MAAM,IAAI,GAAG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AE,SAAS,EAAE,WAAW,EAAE,CAAA;IACnC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAEX,MAAM,KAAK,GAAG,oBAAoB,CAChC,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,WAAW,CACjB,CAAA;IAED,aAAa,CAAC,KAAK,CAAC,CAAA;IAEpB,OAAO,KAAK,CAAA;AACd,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA"}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "@dvashim/store",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
- "version": "1.4.5",
7
+ "version": "1.4.6",
8
8
  "author": {
9
9
  "email": "aleksei@dvashim.dev",
10
10
  "name": "Aleksei Reznichenko"