reactjrx 1.58.0 → 1.59.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 CHANGED
@@ -1520,7 +1520,9 @@ const createMutationRunner = ({
1520
1520
  mutationsRunning$.next(mutationsRunning$.getValue() + 1);
1521
1521
  }),
1522
1522
  switchOperator(({ args, options }) => {
1523
- const queryRunner$ = rxjs.defer(() => rxjs.from(options.mutationFn(args))).pipe(
1523
+ const mutationFn = options.mutationFn;
1524
+ const mutationFnObservable = typeof mutationFn === "function" ? rxjs.defer(() => rxjs.from(mutationFn(args))) : mutationFn;
1525
+ const queryRunner$ = mutationFnObservable.pipe(
1524
1526
  retryOnError(options),
1525
1527
  rxjs.take(1),
1526
1528
  rxjs.map((data) => ({ data, isError: false })),
package/dist/index.js CHANGED
@@ -1518,7 +1518,9 @@ const createMutationRunner = ({
1518
1518
  mutationsRunning$.next(mutationsRunning$.getValue() + 1);
1519
1519
  }),
1520
1520
  switchOperator(({ args, options }) => {
1521
- const queryRunner$ = defer(() => from(options.mutationFn(args))).pipe(
1521
+ const mutationFn = options.mutationFn;
1522
+ const mutationFnObservable = typeof mutationFn === "function" ? defer(() => from(mutationFn(args))) : mutationFn;
1523
+ const queryRunner$ = mutationFnObservable.pipe(
1522
1524
  retryOnError(options),
1523
1525
  take(1),
1524
1526
  map((data) => ({ data, isError: false })),
@@ -22,6 +22,9 @@ import { type Query, type QueryResult } from "../types";
22
22
  export type MapOperator = "switch" | "concat" | "merge";
23
23
  export type MutationStatus = "idle" | "pending" | "success" | "error";
24
24
  export type MutationKey = unknown[];
25
+ /**
26
+ * @todo this should be used in a lot of place so we can probably make a helper for that
27
+ */
25
28
  export interface MutationFilters {
26
29
  /**
27
30
  * Match mutation key exactly
@@ -56,7 +59,7 @@ export interface MutationObservedResult<R> extends MutationResult<R> {
56
59
  isPending: boolean;
57
60
  isPaused: boolean;
58
61
  }
59
- export type MutationFn<T, MutationArg> = ((arg: MutationArg) => Promise<T>) | ((arg: MutationArg) => Observable<T>);
62
+ export type MutationFn<T, MutationArg> = Observable<T> | ((arg: MutationArg) => Promise<T>) | ((arg: MutationArg) => Observable<T>);
60
63
  export interface MutationOptions<Result, MutationArg> {
61
64
  enabled?: boolean;
62
65
  retry?: false | number | ((attempt: number, error: unknown) => boolean);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reactjrx",
3
3
  "private": false,
4
- "version": "1.58.0",
4
+ "version": "1.59.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"