@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 +6 -1
- package/dist/useStore.d.ts +5 -6
- package/dist/useStore.d.ts.map +1 -1
- package/dist/useStore.js.map +1 -1
- package/package.json +1 -1
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
|
|
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
|
package/dist/useStore.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Selector } from './types';
|
|
1
|
+
import type { Selector, SourceStore } from './types';
|
|
3
2
|
/**
|
|
4
|
-
* Subscribes a React component to a {@link
|
|
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:
|
|
8
|
+
declare function useStore<T>(store: SourceStore<T>): T;
|
|
10
9
|
/**
|
|
11
|
-
* Subscribes a React component to a {@link
|
|
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:
|
|
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
|
package/dist/useStore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStore.d.ts","sourceRoot":"","sources":["../src/useStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
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"}
|
package/dist/useStore.js.map
CHANGED
|
@@ -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;
|
|
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;AAyB5E,SAAS,QAAQ,CACf,KAAqB,EACrB,QAAyB;IAEzB,MAAM,WAAW,GAAG,MAAM,CAAkB,SAAS,CAAC,CAAA;IACtD,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAA;IAE9B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE;QACxB,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAE7C,MAAM,WAAW,GAAG,GAAG,EAAE,CACvB,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAA;QAEtE,OAAO,EAAE,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"}
|