reactjrx 1.29.1 → 1.29.2
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 +11 -11
- package/dist/index.js +11 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -451,7 +451,7 @@ function useMutation(query, mapOperatorOrOptions, options = {}) {
|
|
|
451
451
|
const switchOperator = mapOperator === "concat" ? rxjs.concatMap : mapOperator === "switch" ? rxjs.switchMap : rxjs.mergeMap;
|
|
452
452
|
const subscription = triggerSubject.current.pipe(
|
|
453
453
|
switchOperator((args) => {
|
|
454
|
-
const
|
|
454
|
+
const isLastMutationCalled = triggerSubject.current.pipe(
|
|
455
455
|
rxjs.take(1),
|
|
456
456
|
rxjs.map(() => mapOperator === "concat"),
|
|
457
457
|
rxjs.startWith(true)
|
|
@@ -464,32 +464,32 @@ function useMutation(query, mapOperatorOrOptions, options = {}) {
|
|
|
464
464
|
rxjs.defer(() => rxjs.from(queryRef.current(args))).pipe(
|
|
465
465
|
querx(optionsRef.current),
|
|
466
466
|
rxjs.first(),
|
|
467
|
-
rxjs.map((
|
|
467
|
+
rxjs.map((data) => ({ data, isError: false })),
|
|
468
468
|
rxjs.catchError((error) => {
|
|
469
469
|
if (optionsRef.current.onError != null) {
|
|
470
470
|
optionsRef.current.onError(error);
|
|
471
471
|
}
|
|
472
|
-
return rxjs.of(
|
|
472
|
+
return rxjs.of({ data: error, isError: true });
|
|
473
473
|
})
|
|
474
474
|
),
|
|
475
|
-
|
|
475
|
+
isLastMutationCalled
|
|
476
476
|
]).pipe(
|
|
477
|
-
rxjs.tap(([
|
|
478
|
-
if (
|
|
477
|
+
rxjs.tap(([{ data, isError }, isLastMutationCalled2]) => {
|
|
478
|
+
if (!isError) {
|
|
479
479
|
if (optionsRef.current.onSuccess != null)
|
|
480
|
-
optionsRef.current.onSuccess(
|
|
480
|
+
optionsRef.current.onSuccess(data);
|
|
481
481
|
}
|
|
482
|
-
if (
|
|
482
|
+
if (isLastMutationCalled2) {
|
|
483
483
|
data$.current.next({
|
|
484
484
|
...data$.current.getValue(),
|
|
485
|
-
...
|
|
485
|
+
...isError ? {
|
|
486
486
|
status: "error",
|
|
487
|
-
error,
|
|
487
|
+
error: data,
|
|
488
488
|
data: void 0
|
|
489
489
|
} : {
|
|
490
490
|
status: "success",
|
|
491
491
|
error: void 0,
|
|
492
|
-
data
|
|
492
|
+
data
|
|
493
493
|
}
|
|
494
494
|
});
|
|
495
495
|
}
|
package/dist/index.js
CHANGED
|
@@ -449,7 +449,7 @@ function useMutation(query, mapOperatorOrOptions, options = {}) {
|
|
|
449
449
|
const switchOperator = mapOperator === "concat" ? concatMap$1 : mapOperator === "switch" ? switchMap : mergeMap;
|
|
450
450
|
const subscription = triggerSubject.current.pipe(
|
|
451
451
|
switchOperator((args) => {
|
|
452
|
-
const
|
|
452
|
+
const isLastMutationCalled = triggerSubject.current.pipe(
|
|
453
453
|
take(1),
|
|
454
454
|
map(() => mapOperator === "concat"),
|
|
455
455
|
startWith(true)
|
|
@@ -462,32 +462,32 @@ function useMutation(query, mapOperatorOrOptions, options = {}) {
|
|
|
462
462
|
defer(() => from(queryRef.current(args))).pipe(
|
|
463
463
|
querx(optionsRef.current),
|
|
464
464
|
first(),
|
|
465
|
-
map((
|
|
465
|
+
map((data) => ({ data, isError: false })),
|
|
466
466
|
catchError((error) => {
|
|
467
467
|
if (optionsRef.current.onError != null) {
|
|
468
468
|
optionsRef.current.onError(error);
|
|
469
469
|
}
|
|
470
|
-
return of(
|
|
470
|
+
return of({ data: error, isError: true });
|
|
471
471
|
})
|
|
472
472
|
),
|
|
473
|
-
|
|
473
|
+
isLastMutationCalled
|
|
474
474
|
]).pipe(
|
|
475
|
-
tap(([
|
|
476
|
-
if (
|
|
475
|
+
tap(([{ data, isError }, isLastMutationCalled2]) => {
|
|
476
|
+
if (!isError) {
|
|
477
477
|
if (optionsRef.current.onSuccess != null)
|
|
478
|
-
optionsRef.current.onSuccess(
|
|
478
|
+
optionsRef.current.onSuccess(data);
|
|
479
479
|
}
|
|
480
|
-
if (
|
|
480
|
+
if (isLastMutationCalled2) {
|
|
481
481
|
data$.current.next({
|
|
482
482
|
...data$.current.getValue(),
|
|
483
|
-
...
|
|
483
|
+
...isError ? {
|
|
484
484
|
status: "error",
|
|
485
|
-
error,
|
|
485
|
+
error: data,
|
|
486
486
|
data: void 0
|
|
487
487
|
} : {
|
|
488
488
|
status: "success",
|
|
489
489
|
error: void 0,
|
|
490
|
-
data
|
|
490
|
+
data
|
|
491
491
|
}
|
|
492
492
|
});
|
|
493
493
|
}
|