@talismn/util 0.5.4 → 0.5.5
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.
@@ -21,5 +21,25 @@ type QueryOptions<Output, Args> = {
|
|
21
21
|
refreshInterval?: number;
|
22
22
|
serializer?: (args: Args) => string;
|
23
23
|
};
|
24
|
+
/**
|
25
|
+
* Creates a shared observable for executing queries with caching, loading states, and automatic refresh capabilities.
|
26
|
+
*
|
27
|
+
* @example
|
28
|
+
* ```typescript
|
29
|
+
* const userQuery$ = getQuery$({
|
30
|
+
* namespace: 'users',
|
31
|
+
* args: { userId: 123 },
|
32
|
+
* queryFn: async ({ userId }) => fetchUser(userId),
|
33
|
+
* defaultValue: null,
|
34
|
+
* refreshInterval: 30000
|
35
|
+
* });
|
36
|
+
*
|
37
|
+
* userQuery$.subscribe(result => {
|
38
|
+
* if (result.status === 'loaded') {
|
39
|
+
* console.log(result.data);
|
40
|
+
* }
|
41
|
+
* });
|
42
|
+
* ```
|
43
|
+
*/
|
24
44
|
export declare const getQuery$: <Output, Args>({ namespace, args, queryFn, defaultValue, refreshInterval, serializer, }: QueryOptions<Output, Args>) => Observable<QueryResult<Output>>;
|
25
45
|
export {};
|
@@ -388,6 +388,26 @@ const getGenericErrorMessage = error => {
|
|
388
388
|
return String(error) || "Unknown error";
|
389
389
|
};
|
390
390
|
|
391
|
+
/**
|
392
|
+
* Creates a shared observable for executing queries with caching, loading states, and automatic refresh capabilities.
|
393
|
+
*
|
394
|
+
* @example
|
395
|
+
* ```typescript
|
396
|
+
* const userQuery$ = getQuery$({
|
397
|
+
* namespace: 'users',
|
398
|
+
* args: { userId: 123 },
|
399
|
+
* queryFn: async ({ userId }) => fetchUser(userId),
|
400
|
+
* defaultValue: null,
|
401
|
+
* refreshInterval: 30000
|
402
|
+
* });
|
403
|
+
*
|
404
|
+
* userQuery$.subscribe(result => {
|
405
|
+
* if (result.status === 'loaded') {
|
406
|
+
* console.log(result.data);
|
407
|
+
* }
|
408
|
+
* });
|
409
|
+
* ```
|
410
|
+
*/
|
391
411
|
const getQuery$ = ({
|
392
412
|
namespace,
|
393
413
|
args,
|
@@ -388,6 +388,26 @@ const getGenericErrorMessage = error => {
|
|
388
388
|
return String(error) || "Unknown error";
|
389
389
|
};
|
390
390
|
|
391
|
+
/**
|
392
|
+
* Creates a shared observable for executing queries with caching, loading states, and automatic refresh capabilities.
|
393
|
+
*
|
394
|
+
* @example
|
395
|
+
* ```typescript
|
396
|
+
* const userQuery$ = getQuery$({
|
397
|
+
* namespace: 'users',
|
398
|
+
* args: { userId: 123 },
|
399
|
+
* queryFn: async ({ userId }) => fetchUser(userId),
|
400
|
+
* defaultValue: null,
|
401
|
+
* refreshInterval: 30000
|
402
|
+
* });
|
403
|
+
*
|
404
|
+
* userQuery$.subscribe(result => {
|
405
|
+
* if (result.status === 'loaded') {
|
406
|
+
* console.log(result.data);
|
407
|
+
* }
|
408
|
+
* });
|
409
|
+
* ```
|
410
|
+
*/
|
391
411
|
const getQuery$ = ({
|
392
412
|
namespace,
|
393
413
|
args,
|
package/dist/talismn-util.esm.js
CHANGED
@@ -382,6 +382,26 @@ const getGenericErrorMessage = error => {
|
|
382
382
|
return String(error) || "Unknown error";
|
383
383
|
};
|
384
384
|
|
385
|
+
/**
|
386
|
+
* Creates a shared observable for executing queries with caching, loading states, and automatic refresh capabilities.
|
387
|
+
*
|
388
|
+
* @example
|
389
|
+
* ```typescript
|
390
|
+
* const userQuery$ = getQuery$({
|
391
|
+
* namespace: 'users',
|
392
|
+
* args: { userId: 123 },
|
393
|
+
* queryFn: async ({ userId }) => fetchUser(userId),
|
394
|
+
* defaultValue: null,
|
395
|
+
* refreshInterval: 30000
|
396
|
+
* });
|
397
|
+
*
|
398
|
+
* userQuery$.subscribe(result => {
|
399
|
+
* if (result.status === 'loaded') {
|
400
|
+
* console.log(result.data);
|
401
|
+
* }
|
402
|
+
* });
|
403
|
+
* ```
|
404
|
+
*/
|
385
405
|
const getQuery$ = ({
|
386
406
|
namespace,
|
387
407
|
args,
|