@veams/status-quo 0.0.1 → 0.0.2
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.
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRef } from 'react';
|
|
2
2
|
import { useStateSubscription } from './state-subscription.js';
|
|
3
3
|
export function useStateFactory(stateFactoryFunction, params = []) {
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const state = useStateSubscription(stateHandler);
|
|
4
|
+
const stateHandler = useRef(stateFactoryFunction(...params));
|
|
5
|
+
const actions = useRef(stateHandler.current.getActions());
|
|
6
|
+
const state = useStateSubscription(stateHandler.current);
|
|
8
7
|
return [state, actions];
|
|
9
8
|
}
|
|
10
9
|
//# sourceMappingURL=state-factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-factory.js","sourceRoot":"","sources":["../../src/hooks/state-factory.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"state-factory.js","sourceRoot":"","sources":["../../src/hooks/state-factory.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAI/D,MAAM,UAAU,eAAe,CAC7B,oBAAoE,EACpE,SAAY,EAAkB;IAE9B,MAAM,YAAY,GAAG,MAAM,CAAC,oBAAoB,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,oBAAoB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAEzD,OAAO,CAAC,KAAK,EAAE,OAAO,CAAW,CAAC;AACpC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRef } from 'react';
|
|
2
2
|
|
|
3
3
|
import { useStateSubscription } from './state-subscription.js';
|
|
4
4
|
|
|
@@ -8,10 +8,9 @@ export function useStateFactory<V, A, P extends unknown[]>(
|
|
|
8
8
|
stateFactoryFunction: (...args: P) => StateSubscriptionHandler<V, A>,
|
|
9
9
|
params: P = [] as unknown as P
|
|
10
10
|
) {
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const state = useStateSubscription(stateHandler);
|
|
11
|
+
const stateHandler = useRef(stateFactoryFunction(...params));
|
|
12
|
+
const actions = useRef(stateHandler.current.getActions());
|
|
13
|
+
const state = useStateSubscription(stateHandler.current);
|
|
15
14
|
|
|
16
15
|
return [state, actions] as [V, A];
|
|
17
16
|
}
|