@legendapp/state 0.9.2-alpha.8 → 0.9.2-alpha.9
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,12 +1,2 @@
|
|
|
1
1
|
import { ObservableComputed, ValidObservableParam } from '../observableInterfaces';
|
|
2
|
-
|
|
3
|
-
* A React hook that creates a new observable and can optionally listen or persist its state.
|
|
4
|
-
*
|
|
5
|
-
* @param value The initial value of the observable or a function that returns the initial value
|
|
6
|
-
* @param observe (optional) Listen to the observable for changes
|
|
7
|
-
* @param persist (optional) PersistOptions for peristing the observable to state
|
|
8
|
-
*
|
|
9
|
-
* @see https://www.legendapp.com/dev/state/react/#usenewobservable
|
|
10
|
-
*/
|
|
11
|
-
declare function useComputed<T>(compute: () => ValidObservableParam<T>, observe?: boolean): [ObservableComputed<T>, T];
|
|
12
|
-
export { useComputed };
|
|
2
|
+
export declare function useComputed<T>(compute: () => ValidObservableParam<T>, observe?: boolean): [ObservableComputed<T>, T];
|
package/src/react/useComputed.js
CHANGED
|
@@ -2,17 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useComputed = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const observableComputed_1 = require("
|
|
5
|
+
const observableComputed_1 = require("../observableComputed");
|
|
6
6
|
const useObservables_1 = require("./useObservables");
|
|
7
|
-
/**
|
|
8
|
-
* A React hook that creates a new observable and can optionally listen or persist its state.
|
|
9
|
-
*
|
|
10
|
-
* @param value The initial value of the observable or a function that returns the initial value
|
|
11
|
-
* @param observe (optional) Listen to the observable for changes
|
|
12
|
-
* @param persist (optional) PersistOptions for peristing the observable to state
|
|
13
|
-
*
|
|
14
|
-
* @see https://www.legendapp.com/dev/state/react/#usenewobservable
|
|
15
|
-
*/
|
|
16
7
|
function useComputed(compute, observe) {
|
|
17
8
|
// Create the observableComputed
|
|
18
9
|
const obs = (0, react_1.useMemo)(() => (0, observableComputed_1.observableComputed)(compute), []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useComputed.js","sourceRoot":"","sources":["../../../src/react/useComputed.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC
|
|
1
|
+
{"version":3,"file":"useComputed.js","sourceRoot":"","sources":["../../../src/react/useComputed.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,8DAA2D;AAE3D,qDAAkD;AAElD,SAAgB,WAAW,CAAI,OAAsC,EAAE,OAAiB;IACpF,gCAAgC;IAChC,MAAM,GAAG,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAA,uCAAkB,EAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,kDAAkD;IAE9G,IAAI,OAAO,KAAK,KAAK,EAAE;QACnB,IAAA,+BAAc,EAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;KAC/B;IAED,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;AAC5B,CAAC;AATD,kCASC"}
|