reactjrx 1.34.0 → 1.40.0
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/dist/index.cjs +1047 -248
- package/dist/index.d.ts +6 -4
- package/dist/index.js +1049 -250
- package/dist/lib/binding/useObserve.d.ts +2 -2
- package/dist/lib/logger.d.ts +48 -0
- package/dist/lib/queries/client/cache/cacheClient.d.ts +12 -0
- package/dist/lib/queries/client/cache/invalidateCache.d.ts +5 -0
- package/dist/lib/queries/client/cache/logger.d.ts +24 -0
- package/dist/lib/queries/client/cache/registerResultInCache.d.ts +8 -0
- package/dist/lib/queries/client/createClient.d.ts +73 -0
- package/dist/lib/queries/client/deduplication/deduplicate.d.ts +3 -0
- package/dist/lib/queries/client/fetch/mapWithComplete.d.ts +4 -0
- package/dist/lib/queries/client/fetch/notifyQueryResult.d.ts +3 -0
- package/dist/lib/queries/client/fetch/queryFetch.d.ts +12 -0
- package/dist/lib/queries/client/invalidation/invalidationClient.d.ts +12 -0
- package/dist/lib/queries/client/invalidation/logger.d.ts +24 -0
- package/dist/lib/queries/client/invalidation/markAsStale.d.ts +8 -0
- package/dist/lib/queries/client/keys/compareKeys.d.ts +4 -0
- package/dist/lib/queries/client/keys/serializeKey.d.ts +3 -0
- package/dist/lib/queries/client/keys/types.d.ts +10 -0
- package/dist/lib/queries/client/operators.d.ts +4 -0
- package/dist/lib/queries/client/refetch/client.d.ts +18 -0
- package/dist/lib/queries/client/store/createQueryStore.d.ts +55 -0
- package/dist/lib/queries/client/store/debugger.d.ts +3 -0
- package/dist/lib/queries/client/store/garbageCache.d.ts +5 -0
- package/dist/lib/queries/client/store/initializeQueryInStore.d.ts +8 -0
- package/dist/lib/queries/client/store/mapStoreQueryToRunnerOptions.d.ts +4 -0
- package/dist/lib/queries/client/store/queryListener.d.ts +3 -0
- package/dist/lib/queries/client/store/updateStoreWithQuery.d.ts +14 -0
- package/dist/lib/queries/client/triggers.d.ts +17 -0
- package/dist/lib/queries/client/types.d.ts +48 -0
- package/dist/lib/queries/react/Provider.d.ts +12 -0
- package/dist/lib/queries/react/helpers.d.ts +27 -0
- package/dist/lib/queries/react/triggers/activityTrigger.d.ts +9 -0
- package/dist/lib/queries/react/triggers/networkTrigger.d.ts +7 -0
- package/dist/lib/queries/react/types.d.ts +13 -0
- package/dist/lib/queries/react/useQuery.d.ts +6 -0
- package/dist/lib/state/useSignal.d.ts +1 -1
- package/dist/lib/state/useSignalValue.d.ts +1 -1
- package/dist/lib/utils/difference.d.ts +1 -0
- package/package.json +1 -1
- package/dist/lib/queries/Provider.d.ts +0 -23
- package/dist/lib/queries/cache/useCreateCacheStore.d.ts +0 -9
- package/dist/lib/queries/deduplication/deduplicate.d.ts +0 -3
- package/dist/lib/queries/deduplication/useQueryStore.d.ts +0 -3
- package/dist/lib/queries/invalidation/autoRefetch.d.ts +0 -4
- package/dist/lib/queries/keys/serializeKey.d.ts +0 -1
- package/dist/lib/queries/keys/withKeyComparison.d.ts +0 -16
- package/dist/lib/queries/operators.d.ts +0 -2
- package/dist/lib/queries/querx.d.ts +0 -3
- package/dist/lib/queries/types.d.ts +0 -10
- package/dist/lib/queries/useQuery.d.ts +0 -12
- /package/dist/lib/queries/{useAsyncQuery.d.ts → react/useAsyncQuery.d.ts} +0 -0
- /package/dist/lib/queries/{useSubscribeEffect.d.ts → react/useSubscribeEffect.d.ts} +0 -0
|
@@ -10,6 +10,6 @@ interface Option<R = undefined> {
|
|
|
10
10
|
export declare function useObserve<T>(source: BehaviorSubject<T>): T;
|
|
11
11
|
export declare function useObserve<T>(source: Observable<T>): T | undefined;
|
|
12
12
|
export declare function useObserve<T>(source: () => Observable<T>, deps: DependencyList): T | undefined;
|
|
13
|
-
export declare function useObserve<T
|
|
14
|
-
export declare function useObserve<T
|
|
13
|
+
export declare function useObserve<T>(source: Observable<T>, options: Option<T>): T;
|
|
14
|
+
export declare function useObserve<T>(source: () => Observable<T>, options: Option<T>, deps: DependencyList): T;
|
|
15
15
|
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export declare function createLogger(env: string): {
|
|
2
|
+
namespaces: {
|
|
3
|
+
name: string;
|
|
4
|
+
style: {
|
|
5
|
+
backgroundColor: string;
|
|
6
|
+
color: string;
|
|
7
|
+
};
|
|
8
|
+
}[];
|
|
9
|
+
namespace(name: string, style?: {
|
|
10
|
+
backgroundColor: string;
|
|
11
|
+
color: string;
|
|
12
|
+
}): any;
|
|
13
|
+
printNamespaces(): {
|
|
14
|
+
namespaces: string;
|
|
15
|
+
styles: string[];
|
|
16
|
+
};
|
|
17
|
+
print(method: "log" | "warn" | "error" | "group", ...message: any[]): any;
|
|
18
|
+
printWithoutNamespace(method: "log" | "warn" | "error" | "group", ...message: any[]): any;
|
|
19
|
+
log(...message: any): any;
|
|
20
|
+
warn(...message: any): any;
|
|
21
|
+
error(...message: any): any;
|
|
22
|
+
group(...message: any): any;
|
|
23
|
+
groupEnd(): any;
|
|
24
|
+
};
|
|
25
|
+
export declare const Logger: {
|
|
26
|
+
namespaces: {
|
|
27
|
+
name: string;
|
|
28
|
+
style: {
|
|
29
|
+
backgroundColor: string;
|
|
30
|
+
color: string;
|
|
31
|
+
};
|
|
32
|
+
}[];
|
|
33
|
+
namespace(name: string, style?: {
|
|
34
|
+
backgroundColor: string;
|
|
35
|
+
color: string;
|
|
36
|
+
}): any;
|
|
37
|
+
printNamespaces(): {
|
|
38
|
+
namespaces: string;
|
|
39
|
+
styles: string[];
|
|
40
|
+
};
|
|
41
|
+
print(method: "log" | "warn" | "error" | "group", ...message: any[]): any;
|
|
42
|
+
printWithoutNamespace(method: "log" | "warn" | "error" | "group", ...message: any[]): any;
|
|
43
|
+
log(...message: any): any;
|
|
44
|
+
warn(...message: any): any;
|
|
45
|
+
error(...message: any): any;
|
|
46
|
+
group(...message: any): any;
|
|
47
|
+
groupEnd(): any;
|
|
48
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type createQueryStore } from "../store/createQueryStore";
|
|
2
|
+
import { type QueryKey } from "../keys/types";
|
|
3
|
+
type CallableUpdater<TQueryFnData> = (oldData: TQueryFnData | undefined) => TQueryFnData | undefined;
|
|
4
|
+
export declare const createCacheClient: <TQueryFnData>({ queryStore }: {
|
|
5
|
+
queryStore: ReturnType<typeof createQueryStore>;
|
|
6
|
+
}) => {
|
|
7
|
+
setQueryData: ({ queryKey, updater }: {
|
|
8
|
+
queryKey: QueryKey;
|
|
9
|
+
updater: TQueryFnData | CallableUpdater<TQueryFnData> | undefined;
|
|
10
|
+
}) => void;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const logger: {
|
|
2
|
+
namespaces: {
|
|
3
|
+
name: string;
|
|
4
|
+
style: {
|
|
5
|
+
backgroundColor: string;
|
|
6
|
+
color: string;
|
|
7
|
+
};
|
|
8
|
+
}[];
|
|
9
|
+
namespace(name: string, style?: {
|
|
10
|
+
backgroundColor: string;
|
|
11
|
+
color: string;
|
|
12
|
+
} | undefined): any;
|
|
13
|
+
printNamespaces(): {
|
|
14
|
+
namespaces: string;
|
|
15
|
+
styles: string[];
|
|
16
|
+
};
|
|
17
|
+
print(method: "log" | "warn" | "error" | "group", ...message: any[]): any;
|
|
18
|
+
printWithoutNamespace(method: "log" | "warn" | "error" | "group", ...message: any[]): any;
|
|
19
|
+
log(...message: any): any;
|
|
20
|
+
warn(...message: any): any;
|
|
21
|
+
error(...message: any): any;
|
|
22
|
+
group(...message: any): any;
|
|
23
|
+
groupEnd(): any;
|
|
24
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type MonoTypeOperatorFunction } from "rxjs";
|
|
2
|
+
import { type QueryStore } from "../store/createQueryStore";
|
|
3
|
+
import { type QueryOptions } from "../types";
|
|
4
|
+
export declare const registerResultInCache: <T>({ queryStore, serializedKey, options }: {
|
|
5
|
+
queryStore: QueryStore;
|
|
6
|
+
serializedKey: string;
|
|
7
|
+
options: QueryOptions<T>;
|
|
8
|
+
}) => MonoTypeOperatorFunction<T>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type Observable, BehaviorSubject } from "rxjs";
|
|
2
|
+
import { type QueryOptions, type QueryFn, type QueryTrigger, type QueryResult } from "./types";
|
|
3
|
+
import { type QueryKey } from "./keys/types";
|
|
4
|
+
export declare const createClient: () => {
|
|
5
|
+
destroy: () => void;
|
|
6
|
+
pipeQueryResult: <R extends Partial<QueryResult<T>>, T>({ options$ }: {
|
|
7
|
+
key: string;
|
|
8
|
+
queryStore: {
|
|
9
|
+
set: (key: string, value: import("./store/createQueryStore").StoreObject<unknown>) => void;
|
|
10
|
+
get: <T_1>(serializedKey: string) => import("./store/createQueryStore").StoreObject<T_1> | undefined;
|
|
11
|
+
get$: (key: string) => Observable<import("./store/createQueryStore").StoreObject<unknown>>;
|
|
12
|
+
delete: (key: string) => void;
|
|
13
|
+
update: <T_2>(key: string, value: Partial<import("./store/createQueryStore").StoreObject<T_2>> | ((value: import("./store/createQueryStore").StoreObject<T_2>) => import("./store/createQueryStore").StoreObject<T_2>)) => void;
|
|
14
|
+
keys: () => IterableIterator<string>;
|
|
15
|
+
updateMany: (value: Partial<import("./store/createQueryStore").StoreObject<unknown>>, predicate?: (storeObject: import("./store/createQueryStore").StoreObject<unknown>) => boolean) => void;
|
|
16
|
+
addRunner: <T_3>(key: string, stream: Observable<{
|
|
17
|
+
options: QueryOptions<T_3>;
|
|
18
|
+
}>) => () => void;
|
|
19
|
+
store$: BehaviorSubject<Map<string, BehaviorSubject<import("./store/createQueryStore").StoreObject<unknown>>>>;
|
|
20
|
+
queryEvent$: Observable<import("./store/createQueryStore").QueryEvent>;
|
|
21
|
+
dispatchQueryEvent: (event: import("./store/createQueryStore").QueryEvent) => void;
|
|
22
|
+
queryTrigger$: Observable<import("./store/createQueryStore").QueryTriggerEvent>;
|
|
23
|
+
dispatchQueryTrigger: (event: import("./store/createQueryStore").QueryTriggerEvent) => void;
|
|
24
|
+
size: () => number;
|
|
25
|
+
destroy: () => void;
|
|
26
|
+
};
|
|
27
|
+
options$: Observable<QueryOptions<T>>;
|
|
28
|
+
refetch$: Observable<QueryTrigger>;
|
|
29
|
+
}) => import("rxjs").MonoTypeOperatorFunction<R>;
|
|
30
|
+
pipeQueryTrigger: <T_4>({ key }: {
|
|
31
|
+
key: string;
|
|
32
|
+
options$: Observable<QueryOptions<T_4>>;
|
|
33
|
+
}) => import("rxjs").MonoTypeOperatorFunction<QueryTrigger>;
|
|
34
|
+
setQueryData: ({ queryKey, updater }: {
|
|
35
|
+
queryKey: QueryKey;
|
|
36
|
+
updater: unknown;
|
|
37
|
+
}) => void;
|
|
38
|
+
invalidateQueries: ({ queryKey, exact, predicate }?: {
|
|
39
|
+
queryKey?: QueryKey | undefined;
|
|
40
|
+
exact?: boolean | undefined;
|
|
41
|
+
predicate?: ((storeObject: import("./store/createQueryStore").StoreObject<unknown>) => boolean) | undefined;
|
|
42
|
+
}) => void;
|
|
43
|
+
query$: <T_5>({ key, fn$: maybeFn$, fn: maybeFn, refetch$, options$ }: {
|
|
44
|
+
key: QueryKey;
|
|
45
|
+
fn?: QueryFn<T_5> | undefined;
|
|
46
|
+
fn$?: Observable<QueryFn<T_5>> | undefined;
|
|
47
|
+
refetch$?: Observable<{
|
|
48
|
+
ignoreStale: boolean;
|
|
49
|
+
}> | undefined;
|
|
50
|
+
options$?: Observable<QueryOptions<T_5>> | undefined;
|
|
51
|
+
}) => {
|
|
52
|
+
result$: Observable<QueryResult<T_5>>;
|
|
53
|
+
};
|
|
54
|
+
queryStore: {
|
|
55
|
+
set: (key: string, value: import("./store/createQueryStore").StoreObject<unknown>) => void;
|
|
56
|
+
get: <T_1>(serializedKey: string) => import("./store/createQueryStore").StoreObject<T_1> | undefined;
|
|
57
|
+
get$: (key: string) => Observable<import("./store/createQueryStore").StoreObject<unknown>>;
|
|
58
|
+
delete: (key: string) => void;
|
|
59
|
+
update: <T_2>(key: string, value: Partial<import("./store/createQueryStore").StoreObject<T_2>> | ((value: import("./store/createQueryStore").StoreObject<T_2>) => import("./store/createQueryStore").StoreObject<T_2>)) => void;
|
|
60
|
+
keys: () => IterableIterator<string>;
|
|
61
|
+
updateMany: (value: Partial<import("./store/createQueryStore").StoreObject<unknown>>, predicate?: (storeObject: import("./store/createQueryStore").StoreObject<unknown>) => boolean) => void;
|
|
62
|
+
addRunner: <T_3>(key: string, stream: Observable<{
|
|
63
|
+
options: QueryOptions<T_3>;
|
|
64
|
+
}>) => () => void;
|
|
65
|
+
store$: BehaviorSubject<Map<string, BehaviorSubject<import("./store/createQueryStore").StoreObject<unknown>>>>;
|
|
66
|
+
queryEvent$: Observable<import("./store/createQueryStore").QueryEvent>;
|
|
67
|
+
dispatchQueryEvent: (event: import("./store/createQueryStore").QueryEvent) => void;
|
|
68
|
+
queryTrigger$: Observable<import("./store/createQueryStore").QueryTriggerEvent>;
|
|
69
|
+
dispatchQueryTrigger: (event: import("./store/createQueryStore").QueryTriggerEvent) => void;
|
|
70
|
+
size: () => number;
|
|
71
|
+
destroy: () => void;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Observable } from "rxjs";
|
|
2
|
+
import { type QueryResult, type QueryFn, type QueryOptions, type QueryTrigger } from "../types";
|
|
3
|
+
import { type createQueryStore } from "../store/createQueryStore";
|
|
4
|
+
export declare const createQueryFetch: <T>({ options$, options, fn, queryStore, serializedKey, trigger, trigger$ }: {
|
|
5
|
+
fn: QueryFn<T>;
|
|
6
|
+
options$: Observable<QueryOptions<T>>;
|
|
7
|
+
options: QueryOptions<T>;
|
|
8
|
+
queryStore: ReturnType<typeof createQueryStore>;
|
|
9
|
+
serializedKey: string;
|
|
10
|
+
trigger: QueryTrigger;
|
|
11
|
+
trigger$: Observable<QueryTrigger>;
|
|
12
|
+
}) => Observable<Partial<QueryResult<T>>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type createQueryStore } from "../store/createQueryStore";
|
|
2
|
+
import { type QueryKey } from "../keys/types";
|
|
3
|
+
export declare const createInvalidationClient: ({ queryStore }: {
|
|
4
|
+
queryStore: ReturnType<typeof createQueryStore>;
|
|
5
|
+
}) => {
|
|
6
|
+
invalidateQueries: ({ queryKey, exact, predicate }?: {
|
|
7
|
+
queryKey?: QueryKey | undefined;
|
|
8
|
+
exact?: boolean | undefined;
|
|
9
|
+
predicate?: ((storeObject: import("../store/createQueryStore").StoreObject<unknown>) => boolean) | undefined;
|
|
10
|
+
}) => void;
|
|
11
|
+
destroy: () => void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const logger: {
|
|
2
|
+
namespaces: {
|
|
3
|
+
name: string;
|
|
4
|
+
style: {
|
|
5
|
+
backgroundColor: string;
|
|
6
|
+
color: string;
|
|
7
|
+
};
|
|
8
|
+
}[];
|
|
9
|
+
namespace(name: string, style?: {
|
|
10
|
+
backgroundColor: string;
|
|
11
|
+
color: string;
|
|
12
|
+
} | undefined): any;
|
|
13
|
+
printNamespaces(): {
|
|
14
|
+
namespaces: string;
|
|
15
|
+
styles: string[];
|
|
16
|
+
};
|
|
17
|
+
print(method: "log" | "warn" | "error" | "group", ...message: any[]): any;
|
|
18
|
+
printWithoutNamespace(method: "log" | "warn" | "error" | "group", ...message: any[]): any;
|
|
19
|
+
log(...message: any): any;
|
|
20
|
+
warn(...message: any): any;
|
|
21
|
+
error(...message: any): any;
|
|
22
|
+
group(...message: any): any;
|
|
23
|
+
groupEnd(): any;
|
|
24
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type MonoTypeOperatorFunction } from "rxjs";
|
|
2
|
+
import { type QueryStore } from "../store/createQueryStore";
|
|
3
|
+
/**
|
|
4
|
+
* @important global query listener
|
|
5
|
+
*/
|
|
6
|
+
export declare const markAsStale: ({ queryStore }: {
|
|
7
|
+
queryStore: QueryStore;
|
|
8
|
+
}) => MonoTypeOperatorFunction<string>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @important
|
|
3
|
+
* The empty key `[]` is a special case and will not
|
|
4
|
+
* be used to register cache, deduplicate, etc. It's a key
|
|
5
|
+
* that is supposed to be valid in its own context (not shareable).
|
|
6
|
+
*
|
|
7
|
+
* It is the equivalent of passing undefined key and can be used
|
|
8
|
+
* on isolated query when there is no need for key.
|
|
9
|
+
*/
|
|
10
|
+
export type QueryKey = readonly unknown[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Observable } from "rxjs";
|
|
2
|
+
import { type QueryOptions, type QueryResult } from "./types";
|
|
3
|
+
export declare const retryOnError: <T>(options: Pick<QueryOptions<T>, "retry">) => <T_1>(source: Observable<T_1>) => Observable<T_1>;
|
|
4
|
+
export declare const mergeResults: <T>(stream$: Observable<Partial<QueryResult<T>>>) => Observable<QueryResult<T>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type MonoTypeOperatorFunction, type Observable } from "rxjs";
|
|
2
|
+
import { type createQueryStore } from "../store/createQueryStore";
|
|
3
|
+
import { type QueryTrigger, type QueryOptions, type QueryResult } from "../types";
|
|
4
|
+
export declare const createRefetchClient: ({ queryStore }: {
|
|
5
|
+
queryStore: ReturnType<typeof createQueryStore>;
|
|
6
|
+
}) => {
|
|
7
|
+
pipeQueryResult: <R extends Partial<QueryResult<T>>, T>({ options$ }: {
|
|
8
|
+
key: string;
|
|
9
|
+
queryStore: ReturnType<typeof createQueryStore>;
|
|
10
|
+
options$: Observable<QueryOptions<T>>;
|
|
11
|
+
refetch$: Observable<QueryTrigger>;
|
|
12
|
+
}) => MonoTypeOperatorFunction<R>;
|
|
13
|
+
pipeQueryTrigger: <T_1>({ key }: {
|
|
14
|
+
key: string;
|
|
15
|
+
options$: Observable<QueryOptions<T_1>>;
|
|
16
|
+
}) => MonoTypeOperatorFunction<QueryTrigger>;
|
|
17
|
+
destroy: () => void;
|
|
18
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { BehaviorSubject, type Observable } from "rxjs";
|
|
2
|
+
import { type QueryKey } from "../keys/types";
|
|
3
|
+
import { type QueryTrigger, type QueryOptions } from "../types";
|
|
4
|
+
export interface StoreObject<T = unknown> {
|
|
5
|
+
queryKey: QueryKey;
|
|
6
|
+
isStale?: boolean;
|
|
7
|
+
lastFetchedAt?: number;
|
|
8
|
+
/**
|
|
9
|
+
* runners push themselves so we can retrieve various
|
|
10
|
+
* options, fn, etc on global listener.
|
|
11
|
+
* Each query runs on its own individual context so they
|
|
12
|
+
* have to register/deregister themselves into the global context.
|
|
13
|
+
*/
|
|
14
|
+
runners: Array<Observable<{
|
|
15
|
+
options: QueryOptions<T>;
|
|
16
|
+
}>>;
|
|
17
|
+
cache_fnResult?: undefined | {
|
|
18
|
+
result: T;
|
|
19
|
+
};
|
|
20
|
+
deduplication_fn?: Observable<T>;
|
|
21
|
+
}
|
|
22
|
+
export type QueryEvent = {
|
|
23
|
+
type: "fetchSuccess";
|
|
24
|
+
key: string;
|
|
25
|
+
} | {
|
|
26
|
+
type: "fetchError";
|
|
27
|
+
key: string;
|
|
28
|
+
} | {
|
|
29
|
+
type: "queryDataSet";
|
|
30
|
+
key: string;
|
|
31
|
+
};
|
|
32
|
+
export interface QueryTriggerEvent {
|
|
33
|
+
key: string;
|
|
34
|
+
trigger: QueryTrigger;
|
|
35
|
+
}
|
|
36
|
+
export type QueryStore = ReturnType<typeof createQueryStore>;
|
|
37
|
+
export declare const createQueryStore: () => {
|
|
38
|
+
set: (key: string, value: StoreObject) => void;
|
|
39
|
+
get: <T>(serializedKey: string) => StoreObject<T> | undefined;
|
|
40
|
+
get$: (key: string) => Observable<StoreObject<unknown>>;
|
|
41
|
+
delete: (key: string) => void;
|
|
42
|
+
update: <T_1>(key: string, value: Partial<StoreObject<T_1>> | ((value: StoreObject<T_1>) => StoreObject<T_1>)) => void;
|
|
43
|
+
keys: () => IterableIterator<string>;
|
|
44
|
+
updateMany: (value: Partial<StoreObject>, predicate?: (storeObject: StoreObject) => boolean) => void;
|
|
45
|
+
addRunner: <T_2>(key: string, stream: Observable<{
|
|
46
|
+
options: QueryOptions<T_2>;
|
|
47
|
+
}>) => () => void;
|
|
48
|
+
store$: BehaviorSubject<Map<string, BehaviorSubject<StoreObject<unknown>>>>;
|
|
49
|
+
queryEvent$: Observable<QueryEvent>;
|
|
50
|
+
dispatchQueryEvent: (event: QueryEvent) => void;
|
|
51
|
+
queryTrigger$: Observable<QueryTriggerEvent>;
|
|
52
|
+
dispatchQueryTrigger: (event: QueryTriggerEvent) => void;
|
|
53
|
+
size: () => number;
|
|
54
|
+
destroy: () => void;
|
|
55
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type OperatorFunction, type Observable } from "rxjs";
|
|
2
|
+
import { type QueryStore } from "./createQueryStore";
|
|
3
|
+
import { type QueryOptions } from "../types";
|
|
4
|
+
import { type QueryKey } from "../keys/types";
|
|
5
|
+
export declare const updateStoreWithQuery: <T extends {
|
|
6
|
+
options: QueryOptions<R>;
|
|
7
|
+
}, R>({ queryStore, serializedKey, runner$, key }: {
|
|
8
|
+
queryStore: QueryStore;
|
|
9
|
+
serializedKey: string;
|
|
10
|
+
key: QueryKey;
|
|
11
|
+
runner$: Observable<{
|
|
12
|
+
options: QueryOptions<R>;
|
|
13
|
+
}>;
|
|
14
|
+
}) => OperatorFunction<T, [T, () => void]>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Observable } from "rxjs";
|
|
2
|
+
import { type QueryOptions } from "./types";
|
|
3
|
+
import { type QueryStore } from "./store/createQueryStore";
|
|
4
|
+
export declare const createQueryTrigger: <T>({ refetch$, options$, queryStore, key }: {
|
|
5
|
+
refetch$: Observable<{
|
|
6
|
+
ignoreStale: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
options$: Observable<QueryOptions<T>>;
|
|
9
|
+
queryStore: QueryStore;
|
|
10
|
+
key: string;
|
|
11
|
+
}) => Observable<import("./types").QueryTrigger | {
|
|
12
|
+
type: string;
|
|
13
|
+
ignoreStale: boolean;
|
|
14
|
+
} | {
|
|
15
|
+
type: string;
|
|
16
|
+
ignoreStale: boolean;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type Observable } from "rxjs";
|
|
2
|
+
import { type QueryKey } from "./keys/types";
|
|
3
|
+
export interface QueryResult<T> {
|
|
4
|
+
data: {
|
|
5
|
+
result: T;
|
|
6
|
+
} | undefined;
|
|
7
|
+
fetchStatus: "fetching" | "paused" | "idle";
|
|
8
|
+
status: "loading" | "error" | "success";
|
|
9
|
+
error: unknown;
|
|
10
|
+
}
|
|
11
|
+
export interface Query {
|
|
12
|
+
}
|
|
13
|
+
export interface QueryCommand<T> {
|
|
14
|
+
key: QueryKey;
|
|
15
|
+
fn$?: Observable<QueryFn<T>>;
|
|
16
|
+
refetch$?: Observable<{
|
|
17
|
+
ignoreStale: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
options$?: Observable<QueryOptions<T>>;
|
|
20
|
+
}
|
|
21
|
+
export type QueryFn<T> = (() => Promise<T>) | (() => Observable<T>) | Observable<T>;
|
|
22
|
+
export interface QueryTrigger {
|
|
23
|
+
type: string;
|
|
24
|
+
ignoreStale: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface QueryOptions<T = unknown> {
|
|
27
|
+
enabled?: boolean;
|
|
28
|
+
retry?: false | number | ((attempt: number, error: unknown) => boolean);
|
|
29
|
+
/**
|
|
30
|
+
* @important
|
|
31
|
+
* The hook with the lowest value will be taken into account
|
|
32
|
+
*/
|
|
33
|
+
staleTime?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Force the new query to be marked as stale. Only on first trigger
|
|
36
|
+
*/
|
|
37
|
+
markStale?: boolean;
|
|
38
|
+
cacheTime?: number;
|
|
39
|
+
/**
|
|
40
|
+
* @important
|
|
41
|
+
* interval is paused until the query finish fetching. This avoid infinite
|
|
42
|
+
* loop of refetch
|
|
43
|
+
*/
|
|
44
|
+
refetchInterval?: number | false | ((data: QueryResult<T>["data"] | undefined, query: Query) => number | false);
|
|
45
|
+
terminateOnFirstResult?: boolean;
|
|
46
|
+
onError?: (error: unknown) => void;
|
|
47
|
+
onSuccess?: (data: T) => void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type createClient } from "../client/createClient";
|
|
3
|
+
export declare const Context: import("react").Context<{
|
|
4
|
+
client: ReturnType<typeof createClient>;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const Provider: import("react").MemoExoticComponent<({ children, client }: {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
client: ReturnType<typeof createClient>;
|
|
9
|
+
}) => import("react/jsx-runtime").JSX.Element>;
|
|
10
|
+
export declare const useReactJrxProvider: () => {
|
|
11
|
+
client: ReturnType<typeof createClient>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type QueryFn } from "../client/types";
|
|
2
|
+
import { type UseQueryOptions } from "./types";
|
|
3
|
+
export declare const useQueryParams: <T>({ queryKey, queryFn, ...options }: {
|
|
4
|
+
queryKey?: any[] | undefined;
|
|
5
|
+
queryFn?: QueryFn<T> | undefined;
|
|
6
|
+
} & UseQueryOptions<T>) => {
|
|
7
|
+
current: import("rxjs").BehaviorSubject<{
|
|
8
|
+
queryKey: any[] | undefined;
|
|
9
|
+
options: {
|
|
10
|
+
refetchOnWindowFocus?: boolean | "always" | ((query: import("../client/types").Query) => boolean | "always") | undefined;
|
|
11
|
+
refetchOnReconnect?: boolean | "always" | ((query: import("../client/types").Query) => boolean | "always") | undefined;
|
|
12
|
+
refetchOnMount?: boolean | "always" | ((query: import("../client/types").Query) => boolean | "always") | undefined;
|
|
13
|
+
enabled?: boolean | undefined;
|
|
14
|
+
retry?: number | false | ((attempt: number, error: unknown) => boolean) | undefined;
|
|
15
|
+
staleTime?: number | undefined;
|
|
16
|
+
markStale?: boolean | undefined;
|
|
17
|
+
cacheTime?: number | undefined;
|
|
18
|
+
refetchInterval?: number | false | ((data: {
|
|
19
|
+
result: T;
|
|
20
|
+
} | undefined, query: import("../client/types").Query) => number | false) | undefined;
|
|
21
|
+
terminateOnFirstResult?: boolean | undefined;
|
|
22
|
+
onError?: ((error: unknown) => void) | undefined;
|
|
23
|
+
onSuccess?: ((data: T) => void) | undefined;
|
|
24
|
+
};
|
|
25
|
+
queryFn: QueryFn<T> | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Observable } from "rxjs";
|
|
2
|
+
import { type UseQueryOptions } from "../types";
|
|
3
|
+
export declare const createActivityTrigger: <T>(params$: Observable<{
|
|
4
|
+
options: UseQueryOptions<T>;
|
|
5
|
+
}>) => Observable<{
|
|
6
|
+
ignoreStale: boolean;
|
|
7
|
+
} | {
|
|
8
|
+
ignoreStale: boolean;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Query, type QueryOptions } from "../client/types";
|
|
2
|
+
export interface UseQueryOptions<R = unknown> extends QueryOptions<R> {
|
|
3
|
+
refetchOnWindowFocus?: boolean | "always" | ((query: Query) => boolean | "always");
|
|
4
|
+
refetchOnReconnect?: boolean | "always" | ((query: Query) => boolean | "always");
|
|
5
|
+
refetchOnMount?: boolean | "always" | ((query: Query) => boolean | "always");
|
|
6
|
+
}
|
|
7
|
+
export interface UseQueryResult<R> {
|
|
8
|
+
data: R | undefined;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
status: "success" | "error" | "loading";
|
|
11
|
+
error: unknown;
|
|
12
|
+
refetch: () => void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type UseQueryResult, type UseQueryOptions } from "./types";
|
|
2
|
+
import { type QueryFn } from "../client/types";
|
|
3
|
+
export declare function useQuery<T>({ queryKey, queryFn, ...options }: {
|
|
4
|
+
queryKey?: any[];
|
|
5
|
+
queryFn?: QueryFn<T>;
|
|
6
|
+
} & UseQueryOptions<T>): UseQueryResult<T>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type Signal } from "./signal";
|
|
2
|
-
export declare const useSignal: <S
|
|
2
|
+
export declare const useSignal: <S>(signal: Signal<S, S>) => readonly [S, (stateOrUpdater: typeof import("./constants").SIGNAL_RESET | S | ((prev: S) => S)) => void];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type Signal } from "./signal";
|
|
2
|
-
export declare const useSignalValue: <S
|
|
2
|
+
export declare const useSignalValue: <S>(signal: Signal<S, S>, key?: string) => S;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const difference: <T>(a: T[], b: T[]) => T[];
|
package/package.json
CHANGED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
2
|
-
import { type BehaviorSubject } from "rxjs";
|
|
3
|
-
type CacheStore = Record<string, {
|
|
4
|
-
value: any;
|
|
5
|
-
date: number;
|
|
6
|
-
ttl: number;
|
|
7
|
-
}>;
|
|
8
|
-
export declare const Context: import("react").Context<{
|
|
9
|
-
cacheStore: {
|
|
10
|
-
current: BehaviorSubject<CacheStore>;
|
|
11
|
-
};
|
|
12
|
-
queryStore: import("./deduplication/useQueryStore").QueryStore;
|
|
13
|
-
} | undefined>;
|
|
14
|
-
export declare const Provider: import("react").MemoExoticComponent<({ children }: {
|
|
15
|
-
children: ReactNode;
|
|
16
|
-
}) => import("react/jsx-runtime").JSX.Element>;
|
|
17
|
-
export declare const useProvider: () => {
|
|
18
|
-
cacheStore?: {
|
|
19
|
-
current: BehaviorSubject<CacheStore>;
|
|
20
|
-
} | undefined;
|
|
21
|
-
queryStore?: import("./deduplication/useQueryStore").QueryStore | undefined;
|
|
22
|
-
};
|
|
23
|
-
export {};
|