@hexdspace/react 0.0.6 → 0.0.7
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.d.ts +1 -1
- package/dist/index.js +5 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -91,6 +91,6 @@ type ResponsiveMutation<Args, Res> = {
|
|
|
91
91
|
onSuccess?: (data: Res) => void;
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
declare function useResponsiveMutation<Args, Res>(responsiveMutation: ResponsiveMutation<Args, Res
|
|
94
|
+
declare function useResponsiveMutation<Args, Res>(responsiveMutation: ResponsiveMutation<Args, Res>, queryClient: QueryClient): _tanstack_react_query.UseMutationResult<UIOk<Res>, UIFail, Args, OptimisticSnapshot | undefined>;
|
|
95
95
|
|
|
96
96
|
export { type CacheInstruction, type CustomInstruction, DEFAULT_NOTIFICATION_CHANNEL, type Instruction, type InstructionContext, type Notification, type NotificationAction, NotificationHost, type NotificationInstruction, type NotificationVariant, NotifierController, NotifierProvider, type OptimisticSnapshot, type ResponsiveMutation, type UIFail, type UIOk, type UIResult, notifierController, ui, useNotifierController, useResponsiveMutation };
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var ui = {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
// src/util/responsive-query/use-responsive-mutation.ts
|
|
28
|
-
import { useMutation
|
|
28
|
+
import { useMutation } from "@tanstack/react-query";
|
|
29
29
|
|
|
30
30
|
// src/feature/notifier/entity/notification-bus.ts
|
|
31
31
|
var NotificationBus = class {
|
|
@@ -238,9 +238,8 @@ var ToastContent = ({ notification }) => {
|
|
|
238
238
|
};
|
|
239
239
|
|
|
240
240
|
// src/util/responsive-query/use-responsive-mutation.ts
|
|
241
|
-
function useResponsiveMutation(responsiveMutation) {
|
|
241
|
+
function useResponsiveMutation(responsiveMutation, queryClient) {
|
|
242
242
|
const { mutationFn, optimistic, onSuccess } = responsiveMutation;
|
|
243
|
-
const qc = useQueryClient();
|
|
244
243
|
return useMutation({
|
|
245
244
|
mutationFn: async (args) => {
|
|
246
245
|
const res = await mutationFn(args);
|
|
@@ -249,15 +248,15 @@ function useResponsiveMutation(responsiveMutation) {
|
|
|
249
248
|
},
|
|
250
249
|
onMutate: async (args) => {
|
|
251
250
|
if (!optimistic) return void 0;
|
|
252
|
-
const snapshot = await optimistic(args, { queryClient
|
|
251
|
+
const snapshot = await optimistic(args, { queryClient });
|
|
253
252
|
return snapshot ?? void 0;
|
|
254
253
|
},
|
|
255
254
|
onError: (err, _args, ctx) => {
|
|
256
255
|
if (ctx) void ctx.rollback();
|
|
257
|
-
executeEffects(err.effects, { queryClient
|
|
256
|
+
executeEffects(err.effects, { queryClient });
|
|
258
257
|
},
|
|
259
258
|
onSuccess: (res) => {
|
|
260
|
-
executeEffects(res.effects, { queryClient
|
|
259
|
+
executeEffects(res.effects, { queryClient });
|
|
261
260
|
onSuccess?.(res.value);
|
|
262
261
|
}
|
|
263
262
|
});
|