@mmstack/resource 19.6.3 → 19.6.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.
|
@@ -11,6 +11,17 @@ type NextRequest<TMethod extends HttpResourceRequest['method'], TMutation> = TMe
|
|
|
11
11
|
body: TMutation;
|
|
12
12
|
method: TMethod;
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Object form of the `queue` option. Enabling the queue serializes mutations
|
|
16
|
+
* into a FIFO that runs one-at-a-time.
|
|
17
|
+
*/
|
|
18
|
+
export type MutationQueueOptions = {
|
|
19
|
+
/**
|
|
20
|
+
* Reactive queue key. When its returned value changes, the *pending* (not-yet-fired)
|
|
21
|
+
* queued mutations are dropped; an in-flight mutation is unaffected. e.g. `key: () => selectedId()`.
|
|
22
|
+
*/
|
|
23
|
+
key?: () => string | number;
|
|
24
|
+
};
|
|
14
25
|
/**
|
|
15
26
|
* Options for configuring a `mutationResource`. Inherits from
|
|
16
27
|
* `QueryResourceOptions` (minus options that don't apply to mutations:
|
|
@@ -62,10 +73,13 @@ export type MutationResourceOptions<TResult, TRaw = TResult, TMutation = TResult
|
|
|
62
73
|
*/
|
|
63
74
|
onSettled?: (ctx: NoInfer<TCTX>) => void;
|
|
64
75
|
/**
|
|
65
|
-
*
|
|
76
|
+
* Queue mutations and run them one-at-a-time in series, instead of latest-wins
|
|
77
|
+
* superseding (e.g. while offline or the circuit breaker is open). Pass
|
|
78
|
+
* {@link MutationQueueOptions} for a reactive `key` that resets the pending queue.
|
|
79
|
+
* The pending queue can also be cleared via `ref.clearQueue()`.
|
|
66
80
|
* @default false
|
|
67
81
|
*/
|
|
68
|
-
queue?: boolean;
|
|
82
|
+
queue?: boolean | MutationQueueOptions;
|
|
69
83
|
/**
|
|
70
84
|
* Cache entries to invalidate after a SUCCESSFUL mutation — the declarative
|
|
71
85
|
* alternative to calling `injectQueryCache().invalidatePrefix(...)` in `onSuccess`.
|
|
@@ -125,6 +139,11 @@ export type MutationResourceRef<TResult, TMutation = TResult, TICTX = void> = Om
|
|
|
125
139
|
* This can be useful for tracking the state of the mutation or for displaying loading indicators.
|
|
126
140
|
*/
|
|
127
141
|
current: Signal<TMutation | null>;
|
|
142
|
+
/**
|
|
143
|
+
* Drops all *pending* queued mutations; an in-flight mutation is unaffected.
|
|
144
|
+
* Noops when `queue` is not enabled.
|
|
145
|
+
*/
|
|
146
|
+
clearQueue: () => void;
|
|
128
147
|
};
|
|
129
148
|
/**
|
|
130
149
|
* Creates a resource for performing mutations (e.g., POST, PUT, PATCH, DELETE requests).
|