@legendapp/state 3.0.0-alpha.1 → 3.0.0-alpha.3
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/.DS_Store +0 -0
- package/CHANGELOG.md +1 -831
- package/LICENSE +1 -21
- package/README.md +1 -141
- package/as/arrayAsRecord.d.mts +5 -0
- package/as/arrayAsRecord.d.ts +5 -0
- package/as/arrayAsRecord.js +28 -0
- package/as/arrayAsRecord.mjs +26 -0
- package/as/arrayAsSet.d.mts +5 -0
- package/as/arrayAsSet.d.ts +5 -0
- package/as/arrayAsSet.js +13 -0
- package/as/arrayAsSet.mjs +11 -0
- package/as/arrayAsString.d.mts +5 -0
- package/as/arrayAsString.d.ts +5 -0
- package/as/arrayAsString.js +13 -0
- package/as/arrayAsString.mjs +11 -0
- package/as/numberAsString.d.mts +5 -0
- package/as/numberAsString.d.ts +5 -0
- package/as/numberAsString.js +13 -0
- package/as/numberAsString.mjs +11 -0
- package/as/recordAsArray.d.mts +5 -0
- package/as/recordAsArray.d.ts +5 -0
- package/as/recordAsArray.js +25 -0
- package/as/recordAsArray.mjs +23 -0
- package/as/recordAsString.d.mts +5 -0
- package/as/recordAsString.d.ts +5 -0
- package/as/recordAsString.js +13 -0
- package/as/recordAsString.mjs +11 -0
- package/as/setAsArray.d.mts +5 -0
- package/as/setAsArray.d.ts +5 -0
- package/as/setAsArray.js +13 -0
- package/as/setAsArray.mjs +11 -0
- package/as/setAsString.d.mts +5 -0
- package/as/setAsString.d.ts +5 -0
- package/as/setAsString.js +13 -0
- package/as/setAsString.mjs +11 -0
- package/as/stringAsArray.d.mts +5 -0
- package/as/stringAsArray.d.ts +5 -0
- package/as/stringAsArray.js +13 -0
- package/as/stringAsArray.mjs +11 -0
- package/as/stringAsNumber.d.mts +5 -0
- package/as/stringAsNumber.d.ts +5 -0
- package/as/stringAsNumber.js +16 -0
- package/as/stringAsNumber.mjs +14 -0
- package/as/stringAsRecord.d.mts +5 -0
- package/as/stringAsRecord.d.ts +5 -0
- package/as/stringAsRecord.js +15 -0
- package/as/stringAsRecord.mjs +13 -0
- package/as/stringAsSet.d.mts +5 -0
- package/as/stringAsSet.d.ts +5 -0
- package/as/stringAsSet.js +13 -0
- package/as/stringAsSet.mjs +11 -0
- package/babel.d.mts +21 -0
- package/babel.d.ts +21 -2
- package/babel.js +57 -53
- package/babel.mjs +65 -0
- package/config/enable$GetSet.js +13 -14
- package/config/enable$GetSet.mjs +13 -14
- package/config/enableReactComponents.d.mts +9 -0
- package/config/enableReactComponents.d.ts +4 -2
- package/config/enableReactComponents.js +13 -10
- package/config/enableReactComponents.mjs +13 -10
- package/config/enableReactNativeComponents.d.mts +22 -0
- package/config/enableReactNativeComponents.d.ts +6 -4
- package/config/enableReactNativeComponents.js +43 -47
- package/config/enableReactNativeComponents.mjs +43 -47
- package/config/enableReactTracking.d.mts +7 -0
- package/config/enableReactTracking.d.ts +3 -2
- package/config/enableReactTracking.js +33 -38
- package/config/enableReactTracking.mjs +33 -38
- package/config/enableReactUse.d.mts +10 -0
- package/config/enableReactUse.d.ts +4 -1
- package/config/enableReactUse.js +15 -14
- package/config/enableReactUse.mjs +15 -14
- package/config/{enable$GetSet.d.ts → enable_GetSet.d.mts} +4 -2
- package/config/enable_GetSet.d.ts +10 -0
- package/config/enable_PeekAssign.d.mts +10 -0
- package/config/enable_PeekAssign.d.ts +4 -2
- package/config/enable_PeekAssign.js +13 -14
- package/config/enable_PeekAssign.mjs +13 -14
- package/helpers/pageHash.d.mts +9 -0
- package/helpers/pageHash.d.ts +2 -0
- package/helpers/pageHash.js +25 -30
- package/helpers/pageHash.mjs +25 -30
- package/helpers/pageHashParams.d.mts +9 -0
- package/helpers/pageHashParams.d.ts +2 -0
- package/helpers/pageHashParams.js +34 -37
- package/helpers/pageHashParams.mjs +34 -37
- package/helpers/time.d.mts +6 -0
- package/helpers/time.d.ts +6 -3
- package/helpers/time.js +17 -17
- package/helpers/time.mjs +17 -17
- package/helpers/trackHistory.d.mts +6 -0
- package/helpers/trackHistory.d.ts +4 -2
- package/helpers/trackHistory.js +13 -16
- package/helpers/trackHistory.mjs +13 -16
- package/helpers/undoRedo.d.mts +37 -0
- package/helpers/undoRedo.d.ts +5 -3
- package/helpers/undoRedo.js +59 -94
- package/helpers/undoRedo.mjs +59 -94
- package/index.d.mts +404 -0
- package/index.d.ts +371 -28
- package/index.js +2015 -2166
- package/index.mjs +2015 -2166
- package/package.json +254 -195
- package/persist-plugins/async-storage.d.mts +18 -0
- package/persist-plugins/async-storage.d.ts +6 -3
- package/persist-plugins/async-storage.js +79 -86
- package/persist-plugins/async-storage.mjs +79 -86
- package/persist-plugins/indexeddb.d.mts +29 -0
- package/persist-plugins/indexeddb.d.ts +6 -3
- package/persist-plugins/indexeddb.js +331 -352
- package/persist-plugins/indexeddb.mjs +331 -352
- package/persist-plugins/local-storage.d.mts +23 -0
- package/persist-plugins/local-storage.d.ts +8 -5
- package/persist-plugins/local-storage.js +74 -76
- package/persist-plugins/local-storage.mjs +74 -76
- package/persist-plugins/mmkv.d.mts +18 -0
- package/persist-plugins/mmkv.d.ts +6 -3
- package/persist-plugins/mmkv.js +82 -86
- package/persist-plugins/mmkv.mjs +82 -86
- package/react-hooks/createObservableHook.d.mts +5 -0
- package/react-hooks/createObservableHook.d.ts +4 -1
- package/react-hooks/createObservableHook.js +29 -30
- package/react-hooks/createObservableHook.mjs +25 -30
- package/react-hooks/useHover.d.mts +5 -0
- package/react-hooks/useHover.d.ts +5 -3
- package/react-hooks/useHover.js +29 -29
- package/react-hooks/useHover.mjs +29 -29
- package/react-hooks/useMeasure.d.mts +9 -0
- package/react-hooks/useMeasure.d.ts +5 -2
- package/react-hooks/useMeasure.js +30 -32
- package/react-hooks/useMeasure.mjs +30 -32
- package/react-hooks/useObservableNextRouter.d.mts +35 -0
- package/react-hooks/useObservableNextRouter.d.ts +9 -7
- package/react-hooks/useObservableNextRouter.js +64 -77
- package/react-hooks/useObservableNextRouter.mjs +60 -77
- package/react.d.mts +157 -0
- package/react.d.ts +157 -21
- package/react.js +458 -749
- package/react.mjs +457 -752
- package/sync-plugins/crud.d.mts +54 -0
- package/sync-plugins/crud.d.ts +12 -10
- package/sync-plugins/crud.js +253 -270
- package/sync-plugins/crud.mjs +253 -270
- package/sync-plugins/fetch.d.mts +21 -0
- package/sync-plugins/fetch.d.ts +7 -4
- package/sync-plugins/fetch.js +50 -37
- package/sync-plugins/fetch.mjs +50 -37
- package/sync-plugins/keel.d.mts +108 -0
- package/sync-plugins/keel.d.ts +17 -15
- package/sync-plugins/keel.js +229 -462
- package/sync-plugins/keel.mjs +227 -464
- package/sync-plugins/supabase.d.mts +39 -0
- package/sync-plugins/supabase.d.ts +16 -14
- package/sync-plugins/supabase.js +128 -128
- package/sync-plugins/supabase.mjs +128 -128
- package/sync-plugins/tanstack-query.d.mts +14 -0
- package/sync-plugins/tanstack-query.d.ts +7 -4
- package/sync-plugins/tanstack-query.js +51 -57
- package/sync-plugins/tanstack-query.mjs +51 -57
- package/sync-plugins/tanstack-react-query.d.mts +8 -0
- package/sync-plugins/tanstack-react-query.d.ts +6 -1
- package/sync-plugins/tanstack-react-query.js +2 -2
- package/sync-plugins/tanstack-react-query.mjs +2 -2
- package/sync.d.mts +351 -0
- package/sync.d.ts +349 -9
- package/sync.js +910 -964
- package/sync.mjs +920 -974
- package/trace.d.mts +9 -0
- package/trace.d.ts +9 -4
- package/trace.js +72 -62
- package/trace.mjs +72 -62
- package/types/babel.d.ts +1 -12
- package/babel.js.map +0 -1
- package/config/enable$GetSet.js.map +0 -1
- package/config/enable$GetSet.mjs.map +0 -1
- package/config/enableReactComponents.js.map +0 -1
- package/config/enableReactComponents.mjs.map +0 -1
- package/config/enableReactNativeComponents.js.map +0 -1
- package/config/enableReactNativeComponents.mjs.map +0 -1
- package/config/enableReactTracking.js.map +0 -1
- package/config/enableReactTracking.mjs.map +0 -1
- package/config/enableReactUse.js.map +0 -1
- package/config/enableReactUse.mjs.map +0 -1
- package/config/enable_PeekAssign.js.map +0 -1
- package/config/enable_PeekAssign.mjs.map +0 -1
- package/helpers/pageHash.js.map +0 -1
- package/helpers/pageHash.mjs.map +0 -1
- package/helpers/pageHashParams.js.map +0 -1
- package/helpers/pageHashParams.mjs.map +0 -1
- package/helpers/time.js.map +0 -1
- package/helpers/time.mjs.map +0 -1
- package/helpers/trackHistory.js.map +0 -1
- package/helpers/trackHistory.mjs.map +0 -1
- package/helpers/undoRedo.js.map +0 -1
- package/helpers/undoRedo.mjs.map +0 -1
- package/history.d.ts +0 -1
- package/history.js +0 -24
- package/history.js.map +0 -1
- package/history.mjs +0 -22
- package/history.mjs.map +0 -1
- package/index.js.map +0 -1
- package/index.mjs.map +0 -1
- package/persist-plugins/async-storage.js.map +0 -1
- package/persist-plugins/async-storage.mjs.map +0 -1
- package/persist-plugins/indexeddb.js.map +0 -1
- package/persist-plugins/indexeddb.mjs.map +0 -1
- package/persist-plugins/local-storage.js.map +0 -1
- package/persist-plugins/local-storage.mjs.map +0 -1
- package/persist-plugins/mmkv.js.map +0 -1
- package/persist-plugins/mmkv.mjs.map +0 -1
- package/react-hooks/createObservableHook.js.map +0 -1
- package/react-hooks/createObservableHook.mjs.map +0 -1
- package/react-hooks/useHover.js.map +0 -1
- package/react-hooks/useHover.mjs.map +0 -1
- package/react-hooks/useMeasure.js.map +0 -1
- package/react-hooks/useMeasure.mjs.map +0 -1
- package/react-hooks/useObservableNextRouter.js.map +0 -1
- package/react-hooks/useObservableNextRouter.mjs.map +0 -1
- package/react.js.map +0 -1
- package/react.mjs.map +0 -1
- package/src/ObservableObject.ts +0 -1350
- package/src/ObservablePrimitive.ts +0 -62
- package/src/babel/index.ts +0 -83
- package/src/batching.ts +0 -357
- package/src/computed.ts +0 -18
- package/src/config/enable$GetSet.ts +0 -30
- package/src/config/enableReactComponents.ts +0 -26
- package/src/config/enableReactNativeComponents.ts +0 -102
- package/src/config/enableReactTracking.ts +0 -62
- package/src/config/enableReactUse.ts +0 -32
- package/src/config/enable_PeekAssign.ts +0 -31
- package/src/config.ts +0 -47
- package/src/createObservable.ts +0 -47
- package/src/event.ts +0 -26
- package/src/globals.ts +0 -235
- package/src/helpers/pageHash.ts +0 -41
- package/src/helpers/pageHashParams.ts +0 -55
- package/src/helpers/time.ts +0 -30
- package/src/helpers/trackHistory.ts +0 -29
- package/src/helpers/undoRedo.ts +0 -111
- package/src/helpers.ts +0 -231
- package/src/is.ts +0 -63
- package/src/linked.ts +0 -17
- package/src/observable.ts +0 -32
- package/src/observableInterfaces.ts +0 -151
- package/src/observableTypes.ts +0 -232
- package/src/observe.ts +0 -89
- package/src/old-plugins/firebase.ts +0 -1053
- package/src/onChange.ts +0 -146
- package/src/persist/configureObservablePersistence.ts +0 -7
- package/src/persist/fieldTransformer.ts +0 -149
- package/src/persist/observablePersistRemoteFunctionsAdapter.ts +0 -39
- package/src/persist/persistObservable.ts +0 -1034
- package/src/persist-plugins/async-storage.ts +0 -99
- package/src/persist-plugins/indexeddb.ts +0 -439
- package/src/persist-plugins/local-storage.ts +0 -86
- package/src/persist-plugins/mmkv.ts +0 -91
- package/src/proxy.ts +0 -28
- package/src/react/Computed.tsx +0 -8
- package/src/react/For.tsx +0 -116
- package/src/react/Memo.tsx +0 -4
- package/src/react/Reactive.tsx +0 -53
- package/src/react/Show.tsx +0 -33
- package/src/react/Switch.tsx +0 -43
- package/src/react/react-globals.ts +0 -3
- package/src/react/reactInterfaces.ts +0 -32
- package/src/react/reactive-observer.tsx +0 -210
- package/src/react/useComputed.ts +0 -36
- package/src/react/useEffectOnce.ts +0 -41
- package/src/react/useIsMounted.ts +0 -16
- package/src/react/useMount.ts +0 -15
- package/src/react/useObservable.ts +0 -24
- package/src/react/useObservableReducer.ts +0 -52
- package/src/react/useObservableState.ts +0 -30
- package/src/react/useObserve.ts +0 -54
- package/src/react/useObserveEffect.ts +0 -40
- package/src/react/usePauseProvider.tsx +0 -16
- package/src/react/useSelector.ts +0 -167
- package/src/react/useUnmount.ts +0 -8
- package/src/react/useWhen.ts +0 -9
- package/src/react-hooks/createObservableHook.ts +0 -53
- package/src/react-hooks/useHover.ts +0 -40
- package/src/react-hooks/useMeasure.ts +0 -48
- package/src/react-hooks/useObservableNextRouter.ts +0 -137
- package/src/retry.ts +0 -71
- package/src/setupTracking.ts +0 -26
- package/src/sync/activateSyncedNode.ts +0 -128
- package/src/sync/configureObservableSync.ts +0 -7
- package/src/sync/persistTypes.ts +0 -216
- package/src/sync/syncHelpers.ts +0 -180
- package/src/sync/syncObservable.ts +0 -1056
- package/src/sync/syncObservableAdapter.ts +0 -31
- package/src/sync/syncTypes.ts +0 -189
- package/src/sync/synced.ts +0 -21
- package/src/sync-plugins/crud.ts +0 -412
- package/src/sync-plugins/fetch.ts +0 -80
- package/src/sync-plugins/keel.ts +0 -495
- package/src/sync-plugins/supabase.ts +0 -249
- package/src/sync-plugins/tanstack-query.ts +0 -113
- package/src/sync-plugins/tanstack-react-query.ts +0 -12
- package/src/trace/traceHelpers.ts +0 -11
- package/src/trace/useTraceListeners.ts +0 -34
- package/src/trace/useTraceUpdates.ts +0 -24
- package/src/trace/useVerifyNotTracking.ts +0 -33
- package/src/trace/useVerifyOneRender.ts +0 -10
- package/src/trackSelector.ts +0 -52
- package/src/tracking.ts +0 -43
- package/src/types/babel.d.ts +0 -12
- package/src/when.ts +0 -75
- package/sync-plugins/crud.js.map +0 -1
- package/sync-plugins/crud.mjs.map +0 -1
- package/sync-plugins/fetch.js.map +0 -1
- package/sync-plugins/fetch.mjs.map +0 -1
- package/sync-plugins/keel.js.map +0 -1
- package/sync-plugins/keel.mjs.map +0 -1
- package/sync-plugins/supabase.js.map +0 -1
- package/sync-plugins/supabase.mjs.map +0 -1
- package/sync-plugins/tanstack-query.js.map +0 -1
- package/sync-plugins/tanstack-query.mjs.map +0 -1
- package/sync-plugins/tanstack-react-query.js.map +0 -1
- package/sync-plugins/tanstack-react-query.mjs.map +0 -1
- package/sync.js.map +0 -1
- package/sync.mjs.map +0 -1
- package/trace.js.map +0 -1
- package/trace.mjs.map +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Observable } from '@legendapp/state';
|
|
2
|
+
import { NextRouter } from 'next/router';
|
|
3
|
+
|
|
4
|
+
type ParsedUrlQuery = {
|
|
5
|
+
[key: string]: string | string[] | undefined;
|
|
6
|
+
};
|
|
7
|
+
interface TransitionOptions {
|
|
8
|
+
shallow?: boolean;
|
|
9
|
+
locale?: string | false;
|
|
10
|
+
scroll?: boolean;
|
|
11
|
+
unstable_skipClientCache?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface ObservableNextRouterState {
|
|
14
|
+
pathname: string;
|
|
15
|
+
hash: string;
|
|
16
|
+
query: ParsedUrlQuery;
|
|
17
|
+
}
|
|
18
|
+
type RouteInfo = Partial<ObservableNextRouterState>;
|
|
19
|
+
interface ParamsUseObservableNextRouterBase {
|
|
20
|
+
transitionOptions?: TransitionOptions;
|
|
21
|
+
method?: 'push' | 'replace';
|
|
22
|
+
subscribe?: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface ParamsUseObservableNextRouter<T extends object> extends ParamsUseObservableNextRouterBase {
|
|
25
|
+
compute: (value: ObservableNextRouterState) => T;
|
|
26
|
+
set: (value: T, previous: T, router: NextRouter) => RouteInfo & {
|
|
27
|
+
transitionOptions?: TransitionOptions;
|
|
28
|
+
method?: 'push' | 'replace';
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
declare function useObservableNextRouter(): Observable<ObservableNextRouterState>;
|
|
32
|
+
declare function useObservableNextRouter<T extends object>(params: ParamsUseObservableNextRouter<T>): Observable<T>;
|
|
33
|
+
declare function useObservableNextRouter(params: ParamsUseObservableNextRouterBase): Observable<ObservableNextRouterState>;
|
|
34
|
+
|
|
35
|
+
export { type ObservableNextRouterState, type ParamsUseObservableNextRouter, type ParamsUseObservableNextRouterBase, useObservableNextRouter };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Observable } from '@legendapp/state';
|
|
2
2
|
import { NextRouter } from 'next/router';
|
|
3
|
+
|
|
3
4
|
type ParsedUrlQuery = {
|
|
4
5
|
[key: string]: string | string[] | undefined;
|
|
5
6
|
};
|
|
@@ -9,25 +10,26 @@ interface TransitionOptions {
|
|
|
9
10
|
scroll?: boolean;
|
|
10
11
|
unstable_skipClientCache?: boolean;
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
+
interface ObservableNextRouterState {
|
|
13
14
|
pathname: string;
|
|
14
15
|
hash: string;
|
|
15
16
|
query: ParsedUrlQuery;
|
|
16
17
|
}
|
|
17
18
|
type RouteInfo = Partial<ObservableNextRouterState>;
|
|
18
|
-
|
|
19
|
+
interface ParamsUseObservableNextRouterBase {
|
|
19
20
|
transitionOptions?: TransitionOptions;
|
|
20
21
|
method?: 'push' | 'replace';
|
|
21
22
|
subscribe?: boolean;
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
+
interface ParamsUseObservableNextRouter<T extends object> extends ParamsUseObservableNextRouterBase {
|
|
24
25
|
compute: (value: ObservableNextRouterState) => T;
|
|
25
26
|
set: (value: T, previous: T, router: NextRouter) => RouteInfo & {
|
|
26
27
|
transitionOptions?: TransitionOptions;
|
|
27
28
|
method?: 'push' | 'replace';
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
declare function useObservableNextRouter(): Observable<ObservableNextRouterState>;
|
|
32
|
+
declare function useObservableNextRouter<T extends object>(params: ParamsUseObservableNextRouter<T>): Observable<T>;
|
|
33
|
+
declare function useObservableNextRouter(params: ParamsUseObservableNextRouterBase): Observable<ObservableNextRouterState>;
|
|
34
|
+
|
|
35
|
+
export { type ObservableNextRouterState, type ParamsUseObservableNextRouter, type ParamsUseObservableNextRouterBase, useObservableNextRouter };
|
|
@@ -3,90 +3,77 @@
|
|
|
3
3
|
var state = require('@legendapp/state');
|
|
4
4
|
var Router = require('next/router');
|
|
5
5
|
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var Router__default = /*#__PURE__*/_interopDefault(Router);
|
|
9
|
+
|
|
10
|
+
// src/react-hooks/useObservableNextRouter.ts
|
|
6
11
|
function isShallowEqual(query1, query2) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
if (!query1 !== !query2) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const keys1 = Object.keys(query1);
|
|
16
|
+
const keys2 = Object.keys(query2);
|
|
17
|
+
if (keys1.length !== keys2.length) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
for (const key of keys1) {
|
|
21
|
+
if (query1[key] !== query2[key]) {
|
|
22
|
+
return false;
|
|
14
23
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
21
26
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
var routes$ = state.observable({});
|
|
28
|
+
var routeParams = {};
|
|
29
|
+
var router;
|
|
25
30
|
routes$.onChange(({ value, getPrevious }) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
else {
|
|
33
|
-
console.error('[legend-state]: Must provide a set method to useObservableNextRouter');
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
const setReturn = setter(value, getPrevious(), router);
|
|
37
|
-
const { pathname, hash, query } = setReturn;
|
|
38
|
-
let { transitionOptions, method } = setReturn;
|
|
39
|
-
method = method || (routeParams === null || routeParams === void 0 ? void 0 : routeParams.method);
|
|
40
|
-
transitionOptions = transitionOptions || (routeParams === null || routeParams === void 0 ? void 0 : routeParams.transitionOptions);
|
|
41
|
-
const prevHash = router.asPath.split('#')[1] || '';
|
|
42
|
-
const change = {};
|
|
43
|
-
// Only include changes that were meant to be changed. For example the user may have
|
|
44
|
-
// only changed the hash so we don't need to push a pathname change.
|
|
45
|
-
if (pathname !== undefined && pathname !== router.pathname) {
|
|
46
|
-
change.pathname = pathname;
|
|
47
|
-
}
|
|
48
|
-
if (hash !== undefined && hash !== prevHash) {
|
|
49
|
-
change.hash = hash;
|
|
50
|
-
}
|
|
51
|
-
if (query !== undefined && !isShallowEqual(query, router.query)) {
|
|
52
|
-
change.query = query;
|
|
53
|
-
}
|
|
54
|
-
// Only push if there are changes
|
|
55
|
-
if (!state.isEmpty(change)) {
|
|
56
|
-
const fn = method === 'replace' ? 'replace' : 'push';
|
|
57
|
-
router[fn](change, undefined, transitionOptions).catch((e) => {
|
|
58
|
-
// workaround for https://github.com/vercel/next.js/issues/37362
|
|
59
|
-
if (!e.cancelled)
|
|
60
|
-
throw e;
|
|
61
|
-
});
|
|
31
|
+
let setter = routeParams == null ? void 0 : routeParams.set;
|
|
32
|
+
if (!setter) {
|
|
33
|
+
if (value.pathname) {
|
|
34
|
+
setter = () => value;
|
|
35
|
+
} else {
|
|
36
|
+
console.error("[legend-state]: Must provide a set method to useObservableNextRouter");
|
|
62
37
|
}
|
|
38
|
+
}
|
|
39
|
+
const setReturn = setter(value, getPrevious(), router);
|
|
40
|
+
const { pathname, hash, query } = setReturn;
|
|
41
|
+
let { transitionOptions, method } = setReturn;
|
|
42
|
+
method = method || (routeParams == null ? void 0 : routeParams.method);
|
|
43
|
+
transitionOptions = transitionOptions || (routeParams == null ? void 0 : routeParams.transitionOptions);
|
|
44
|
+
const prevHash = router.asPath.split("#")[1] || "";
|
|
45
|
+
const change = {};
|
|
46
|
+
if (pathname !== void 0 && pathname !== router.pathname) {
|
|
47
|
+
change.pathname = pathname;
|
|
48
|
+
}
|
|
49
|
+
if (hash !== void 0 && hash !== prevHash) {
|
|
50
|
+
change.hash = hash;
|
|
51
|
+
}
|
|
52
|
+
if (query !== void 0 && !isShallowEqual(query, router.query)) {
|
|
53
|
+
change.query = query;
|
|
54
|
+
}
|
|
55
|
+
if (!state.isEmpty(change)) {
|
|
56
|
+
const fn = method === "replace" ? "replace" : "push";
|
|
57
|
+
router[fn](change, void 0, transitionOptions).catch((e) => {
|
|
58
|
+
if (!e.cancelled)
|
|
59
|
+
throw e;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
63
62
|
});
|
|
64
63
|
function useObservableNextRouter(params) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
routeParams = params;
|
|
79
|
-
// Get the pathname and hash
|
|
80
|
-
const { asPath, pathname, query } = router;
|
|
81
|
-
const hash = asPath.split('#')[1] || '';
|
|
82
|
-
// Run the compute function to get the value of the object
|
|
83
|
-
const computeParams = { pathname, hash, query };
|
|
84
|
-
const obj = compute ? compute(computeParams) : computeParams;
|
|
85
|
-
// Set the object without triggering router.push
|
|
86
|
-
state.setSilently(routes$, obj);
|
|
87
|
-
// Return the observable with the computed values
|
|
88
|
-
return routes$;
|
|
64
|
+
const { subscribe, compute } = params || {};
|
|
65
|
+
try {
|
|
66
|
+
router = typeof window !== "undefined" && !subscribe ? Router__default.default : Router.useRouter();
|
|
67
|
+
} finally {
|
|
68
|
+
router = router || Router.useRouter();
|
|
69
|
+
}
|
|
70
|
+
routeParams = params;
|
|
71
|
+
const { asPath, pathname, query } = router;
|
|
72
|
+
const hash = asPath.split("#")[1] || "";
|
|
73
|
+
const computeParams = { pathname, hash, query };
|
|
74
|
+
const obj = compute ? compute(computeParams) : computeParams;
|
|
75
|
+
state.setSilently(routes$, obj);
|
|
76
|
+
return routes$;
|
|
89
77
|
}
|
|
90
78
|
|
|
91
79
|
exports.useObservableNextRouter = useObservableNextRouter;
|
|
92
|
-
//# sourceMappingURL=useObservableNextRouter.js.map
|
|
@@ -1,90 +1,73 @@
|
|
|
1
1
|
import { observable, isEmpty, setSilently } from '@legendapp/state';
|
|
2
2
|
import Router, { useRouter } from 'next/router';
|
|
3
3
|
|
|
4
|
+
// src/react-hooks/useObservableNextRouter.ts
|
|
4
5
|
function isShallowEqual(query1, query2) {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
if (!query1 !== !query2) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const keys1 = Object.keys(query1);
|
|
10
|
+
const keys2 = Object.keys(query2);
|
|
11
|
+
if (keys1.length !== keys2.length) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
for (const key of keys1) {
|
|
15
|
+
if (query1[key] !== query2[key]) {
|
|
16
|
+
return false;
|
|
7
17
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (keys1.length !== keys2.length) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
for (const key of keys1) {
|
|
14
|
-
if (query1[key] !== query2[key]) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return true;
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
var routes$ = observable({});
|
|
22
|
+
var routeParams = {};
|
|
23
|
+
var router;
|
|
23
24
|
routes$.onChange(({ value, getPrevious }) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
else {
|
|
31
|
-
console.error('[legend-state]: Must provide a set method to useObservableNextRouter');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const setReturn = setter(value, getPrevious(), router);
|
|
35
|
-
const { pathname, hash, query } = setReturn;
|
|
36
|
-
let { transitionOptions, method } = setReturn;
|
|
37
|
-
method = method || (routeParams === null || routeParams === void 0 ? void 0 : routeParams.method);
|
|
38
|
-
transitionOptions = transitionOptions || (routeParams === null || routeParams === void 0 ? void 0 : routeParams.transitionOptions);
|
|
39
|
-
const prevHash = router.asPath.split('#')[1] || '';
|
|
40
|
-
const change = {};
|
|
41
|
-
// Only include changes that were meant to be changed. For example the user may have
|
|
42
|
-
// only changed the hash so we don't need to push a pathname change.
|
|
43
|
-
if (pathname !== undefined && pathname !== router.pathname) {
|
|
44
|
-
change.pathname = pathname;
|
|
45
|
-
}
|
|
46
|
-
if (hash !== undefined && hash !== prevHash) {
|
|
47
|
-
change.hash = hash;
|
|
48
|
-
}
|
|
49
|
-
if (query !== undefined && !isShallowEqual(query, router.query)) {
|
|
50
|
-
change.query = query;
|
|
51
|
-
}
|
|
52
|
-
// Only push if there are changes
|
|
53
|
-
if (!isEmpty(change)) {
|
|
54
|
-
const fn = method === 'replace' ? 'replace' : 'push';
|
|
55
|
-
router[fn](change, undefined, transitionOptions).catch((e) => {
|
|
56
|
-
// workaround for https://github.com/vercel/next.js/issues/37362
|
|
57
|
-
if (!e.cancelled)
|
|
58
|
-
throw e;
|
|
59
|
-
});
|
|
25
|
+
let setter = routeParams == null ? void 0 : routeParams.set;
|
|
26
|
+
if (!setter) {
|
|
27
|
+
if (value.pathname) {
|
|
28
|
+
setter = () => value;
|
|
29
|
+
} else {
|
|
30
|
+
console.error("[legend-state]: Must provide a set method to useObservableNextRouter");
|
|
60
31
|
}
|
|
32
|
+
}
|
|
33
|
+
const setReturn = setter(value, getPrevious(), router);
|
|
34
|
+
const { pathname, hash, query } = setReturn;
|
|
35
|
+
let { transitionOptions, method } = setReturn;
|
|
36
|
+
method = method || (routeParams == null ? void 0 : routeParams.method);
|
|
37
|
+
transitionOptions = transitionOptions || (routeParams == null ? void 0 : routeParams.transitionOptions);
|
|
38
|
+
const prevHash = router.asPath.split("#")[1] || "";
|
|
39
|
+
const change = {};
|
|
40
|
+
if (pathname !== void 0 && pathname !== router.pathname) {
|
|
41
|
+
change.pathname = pathname;
|
|
42
|
+
}
|
|
43
|
+
if (hash !== void 0 && hash !== prevHash) {
|
|
44
|
+
change.hash = hash;
|
|
45
|
+
}
|
|
46
|
+
if (query !== void 0 && !isShallowEqual(query, router.query)) {
|
|
47
|
+
change.query = query;
|
|
48
|
+
}
|
|
49
|
+
if (!isEmpty(change)) {
|
|
50
|
+
const fn = method === "replace" ? "replace" : "push";
|
|
51
|
+
router[fn](change, void 0, transitionOptions).catch((e) => {
|
|
52
|
+
if (!e.cancelled)
|
|
53
|
+
throw e;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
61
56
|
});
|
|
62
57
|
function useObservableNextRouter(params) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
routeParams = params;
|
|
77
|
-
// Get the pathname and hash
|
|
78
|
-
const { asPath, pathname, query } = router;
|
|
79
|
-
const hash = asPath.split('#')[1] || '';
|
|
80
|
-
// Run the compute function to get the value of the object
|
|
81
|
-
const computeParams = { pathname, hash, query };
|
|
82
|
-
const obj = compute ? compute(computeParams) : computeParams;
|
|
83
|
-
// Set the object without triggering router.push
|
|
84
|
-
setSilently(routes$, obj);
|
|
85
|
-
// Return the observable with the computed values
|
|
86
|
-
return routes$;
|
|
58
|
+
const { subscribe, compute } = params || {};
|
|
59
|
+
try {
|
|
60
|
+
router = typeof window !== "undefined" && !subscribe ? Router : useRouter();
|
|
61
|
+
} finally {
|
|
62
|
+
router = router || useRouter();
|
|
63
|
+
}
|
|
64
|
+
routeParams = params;
|
|
65
|
+
const { asPath, pathname, query } = router;
|
|
66
|
+
const hash = asPath.split("#")[1] || "";
|
|
67
|
+
const computeParams = { pathname, hash, query };
|
|
68
|
+
const obj = compute ? compute(computeParams) : computeParams;
|
|
69
|
+
setSilently(routes$, obj);
|
|
70
|
+
return routes$;
|
|
87
71
|
}
|
|
88
72
|
|
|
89
73
|
export { useObservableNextRouter };
|
|
90
|
-
//# sourceMappingURL=useObservableNextRouter.mjs.map
|
package/react.d.mts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, ReactElement, FC, LegacyRef, ComponentClass, ReducerWithoutAction, ReducerStateWithoutAction, DispatchWithoutAction, Reducer, ReducerState, Dispatch, ReducerAction } from 'react';
|
|
3
|
+
import { ObservableParam, Observable, ObservableBoolean, Selector, RecursiveValueOrFunction, ObserveEvent, ObserveOptions, ObserveEventCallback } from '@legendapp/state';
|
|
4
|
+
|
|
5
|
+
declare function Computed({ children }: {
|
|
6
|
+
children: ObservableParam | (() => ReactNode);
|
|
7
|
+
}): ReactElement;
|
|
8
|
+
|
|
9
|
+
type ForItemProps<T, TProps = {}> = {
|
|
10
|
+
item$: Observable<T>;
|
|
11
|
+
id?: string;
|
|
12
|
+
} & TProps;
|
|
13
|
+
declare function For<T, TProps>({ each, optimized: isOptimized, item, itemProps, sortValues, children, }: {
|
|
14
|
+
each?: ObservableParam<T[] | Record<any, T> | Map<any, T>>;
|
|
15
|
+
optimized?: boolean;
|
|
16
|
+
item?: FC<ForItemProps<T, TProps>>;
|
|
17
|
+
itemProps?: TProps;
|
|
18
|
+
sortValues?: (A: T, B: T, AKey: string, BKey: string) => number;
|
|
19
|
+
children?: (value: Observable<T>, id: string | undefined) => ReactElement;
|
|
20
|
+
}): ReactElement | null;
|
|
21
|
+
|
|
22
|
+
declare function usePauseProvider(): {
|
|
23
|
+
PauseProvider: ({ children }: {
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
}) => react.FunctionComponentElement<react.ProviderProps<ObservableBoolean>>;
|
|
26
|
+
isPaused$: ObservableBoolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
declare const Memo: react.MemoExoticComponent<typeof Computed>;
|
|
30
|
+
|
|
31
|
+
type ShapeWithNew$<T> = Partial<Omit<T, 'children'>> & {
|
|
32
|
+
[K in keyof T as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
|
|
33
|
+
} & {
|
|
34
|
+
children?: Selector<ReactNode>;
|
|
35
|
+
};
|
|
36
|
+
interface BindKey<P> {
|
|
37
|
+
handler?: keyof P;
|
|
38
|
+
getValue?: (e: any) => any;
|
|
39
|
+
defaultValue?: any;
|
|
40
|
+
selector?: (propsOut: Record<string, any>, p: Observable<any>) => any;
|
|
41
|
+
}
|
|
42
|
+
type BindKeys<P = any> = Record<keyof P, BindKey<P>>;
|
|
43
|
+
type FCReactiveObject<T> = {
|
|
44
|
+
[K in keyof T]: FC<ShapeWithNew$<T[K]>>;
|
|
45
|
+
};
|
|
46
|
+
type FCReactive<P, P2> = P & FC<ShapeWithNew$<P2> & {
|
|
47
|
+
ref?: LegacyRef<P> | undefined;
|
|
48
|
+
}>;
|
|
49
|
+
interface UseSelectorOptions {
|
|
50
|
+
suspense?: boolean;
|
|
51
|
+
skipCheck?: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface IReactive {
|
|
55
|
+
}
|
|
56
|
+
declare const Reactive: IReactive;
|
|
57
|
+
declare function configureReactive({ components, binders, }: {
|
|
58
|
+
components?: Record<string, FC | ComponentClass<any>>;
|
|
59
|
+
binders?: Record<string, BindKeys>;
|
|
60
|
+
}): void;
|
|
61
|
+
|
|
62
|
+
interface PropsIf<T> {
|
|
63
|
+
if: Selector<T>;
|
|
64
|
+
ifReady?: never;
|
|
65
|
+
}
|
|
66
|
+
interface PropsIfReady<T> {
|
|
67
|
+
if?: never;
|
|
68
|
+
ifReady: Selector<T>;
|
|
69
|
+
}
|
|
70
|
+
interface PropsBase<T> {
|
|
71
|
+
else?: ReactNode | (() => ReactNode);
|
|
72
|
+
wrap?: FC;
|
|
73
|
+
children: ReactNode | ((value?: T) => ReactNode);
|
|
74
|
+
}
|
|
75
|
+
type Props<T> = PropsBase<T> & (PropsIf<T> | PropsIfReady<T>);
|
|
76
|
+
declare function Show<T>(props: Props<T>): ReactElement;
|
|
77
|
+
|
|
78
|
+
declare function Switch<T extends object>({ value, children, }: {
|
|
79
|
+
value?: Selector<T>;
|
|
80
|
+
children: Partial<Record<keyof T | 'null' | 'undefined' | 'default', () => ReactNode>>;
|
|
81
|
+
}): ReactElement | null;
|
|
82
|
+
declare function Switch<T extends string | number | symbol>({ value, children, }: {
|
|
83
|
+
value?: Selector<T>;
|
|
84
|
+
children: Partial<Record<T | 'null' | 'undefined' | 'default', () => ReactNode>>;
|
|
85
|
+
}): ReactElement | null;
|
|
86
|
+
declare function Switch<T extends boolean>({ value, children, }: {
|
|
87
|
+
value?: Selector<T>;
|
|
88
|
+
children: Partial<Record<'false' | 'true' | 'null' | 'undefined' | 'default', () => ReactNode>>;
|
|
89
|
+
}): ReactElement | null;
|
|
90
|
+
declare function Switch<T>({ value, children, }: {
|
|
91
|
+
value?: Selector<T>;
|
|
92
|
+
children: Partial<Record<'undefined' | 'default', () => ReactNode>>;
|
|
93
|
+
}): ReactElement | null;
|
|
94
|
+
|
|
95
|
+
type ShapeWithPick$<T, T2 extends keyof T = keyof T> = Partial<T> & {
|
|
96
|
+
[K in T2 as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
|
|
97
|
+
};
|
|
98
|
+
type ShapeWith$<T> = Partial<T> & {
|
|
99
|
+
[K in keyof T as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
|
|
100
|
+
};
|
|
101
|
+
type ObjectShapeWith$<T> = {
|
|
102
|
+
[K in keyof T]: T[K] extends FC<infer P> ? FC<ShapeWith$<P>> : T[K];
|
|
103
|
+
};
|
|
104
|
+
type ExtractFCPropsType<T> = T extends FC<infer P> ? P : never;
|
|
105
|
+
declare const hasSymbol: false | ((key: string) => symbol);
|
|
106
|
+
declare function observer<P extends FC<any>>(component: P): P;
|
|
107
|
+
declare function reactive<T extends FC<any>>(component: T, bindKeys?: BindKeys<ExtractFCPropsType<T>>): T | FC<ShapeWith$<ExtractFCPropsType<T>>>;
|
|
108
|
+
declare function reactive<T extends FC<any>, T2 extends keyof ExtractFCPropsType<T>>(component: T, bindKeys?: BindKeys<ExtractFCPropsType<T>>): T | FC<ShapeWithPick$<ExtractFCPropsType<T>, T2>>;
|
|
109
|
+
declare function reactiveObserver<T extends FC<any>>(component: T, bindKeys?: BindKeys<ExtractFCPropsType<T>>): T | FC<ShapeWith$<ExtractFCPropsType<T>>>;
|
|
110
|
+
declare function reactiveObserver<T extends FC<any>, T2 extends keyof ExtractFCPropsType<T>>(component: T, bindKeys?: BindKeys<ExtractFCPropsType<T>>): T | FC<ShapeWithPick$<ExtractFCPropsType<T>, T2>>;
|
|
111
|
+
declare function reactiveComponents<P extends Record<string, FC>>(components: P): ObjectShapeWith$<P>;
|
|
112
|
+
|
|
113
|
+
declare function useComputed<T>(compute: () => T | Promise<T>): Observable<T>;
|
|
114
|
+
declare function useComputed<T>(compute: () => T | Promise<T>, deps: any[]): Observable<T>;
|
|
115
|
+
declare function useComputed<T, T2 = T>(compute: (() => T | Promise<T>) | ObservableParam<T>, set: (value: T2) => void): Observable<T>;
|
|
116
|
+
declare function useComputed<T, T2 = T>(compute: (() => T | Promise<T>) | ObservableParam<T>, set: (value: T2) => void, deps: any[]): Observable<T>;
|
|
117
|
+
|
|
118
|
+
declare const useEffectOnce: (effect: () => void | (() => void), deps: any[]) => void;
|
|
119
|
+
|
|
120
|
+
declare function useIsMounted(): Observable<boolean>;
|
|
121
|
+
|
|
122
|
+
declare function useMount(fn: () => (void | (() => void)) | Promise<void>): void;
|
|
123
|
+
declare const useMountOnce: typeof useMount;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* A React hook that creates a new observable
|
|
127
|
+
*
|
|
128
|
+
* @param initialValue The initial value of the observable or a function that returns the initial value
|
|
129
|
+
*
|
|
130
|
+
* @see https://www.legendapp.com/dev/state/react/#useObservable
|
|
131
|
+
*/
|
|
132
|
+
declare function useObservable<T>(): Observable<T | undefined>;
|
|
133
|
+
declare function useObservable<T>(value: Promise<RecursiveValueOrFunction<T>> | (() => RecursiveValueOrFunction<T>) | RecursiveValueOrFunction<T>): Observable<T>;
|
|
134
|
+
declare function useObservable<T>(value: T): Observable<T>;
|
|
135
|
+
declare function useObservable<T>(value?: T): Observable<any>;
|
|
136
|
+
|
|
137
|
+
declare function useObservableReducer<R extends ReducerWithoutAction<any>, I>(reducer: R, initializerArg: I, initializer: (arg: I) => ReducerStateWithoutAction<R>): [Observable<ReducerStateWithoutAction<R>>, DispatchWithoutAction];
|
|
138
|
+
declare function useObservableReducer<R extends ReducerWithoutAction<any>>(reducer: R, initializerArg: ReducerStateWithoutAction<R>, initializer?: undefined): [Observable<ReducerStateWithoutAction<R>>, DispatchWithoutAction];
|
|
139
|
+
declare function useObservableReducer<R extends Reducer<any, any>, I>(reducer: R, initializerArg: I & ReducerState<R>, initializer: (arg: I & ReducerState<R>) => ReducerState<R>): [Observable<ReducerState<R>>, Dispatch<ReducerAction<R>>];
|
|
140
|
+
declare function useObservableReducer<R extends Reducer<any, any>, I>(reducer: R, initializerArg: I, initializer: (arg: I) => ReducerState<R>): [Observable<ReducerState<R>>, Dispatch<ReducerAction<R>>];
|
|
141
|
+
declare function useObservableReducer<R extends Reducer<any, any>>(reducer: R, initialState: ReducerState<R>, initializer?: undefined): [Observable<ReducerState<R>>, Dispatch<ReducerAction<R>>];
|
|
142
|
+
|
|
143
|
+
declare function useObserve<T>(run: (e: ObserveEvent<T>) => T | void, options?: ObserveOptions): () => void;
|
|
144
|
+
declare function useObserve<T>(selector: Selector<T>, reaction?: (e: ObserveEventCallback<T>) => any, options?: ObserveOptions): () => void;
|
|
145
|
+
|
|
146
|
+
declare function useObserveEffect<T>(run: (e: ObserveEvent<T>) => T | void, options?: ObserveOptions): void;
|
|
147
|
+
declare function useObserveEffect<T>(selector: Selector<T>, reaction?: (e: ObserveEventCallback<T>) => any, options?: ObserveOptions): void;
|
|
148
|
+
|
|
149
|
+
declare function useSelector<T>(selector: Selector<T>, options?: UseSelectorOptions): T;
|
|
150
|
+
|
|
151
|
+
declare function useUnmount(fn: () => void): void;
|
|
152
|
+
declare const useUnmountOnce: typeof useUnmount;
|
|
153
|
+
|
|
154
|
+
declare function useWhen<T>(predicate: Selector<T>, effect: (value: T) => any | (() => any)): Promise<any>;
|
|
155
|
+
declare function useWhenReady<T>(predicate: Selector<T>, effect: (value: T) => any | (() => any)): Promise<any>;
|
|
156
|
+
|
|
157
|
+
export { type BindKey, type BindKeys, Computed, type ExtractFCPropsType, type FCReactive, type FCReactiveObject, For, type IReactive, Memo, type ObjectShapeWith$, Reactive, type ShapeWith$, type ShapeWithNew$, type ShapeWithPick$, Show, Switch, type UseSelectorOptions, configureReactive, hasSymbol, observer, reactive, reactiveComponents, reactiveObserver, useComputed, useEffectOnce, useIsMounted, useMount, useMountOnce, useObservable, useObservableReducer, useObserve, useObserveEffect, usePauseProvider, useSelector, useUnmount, useUnmountOnce, useWhen, useWhenReady };
|