Skip to content

Commit dba4769

Browse files
committed
fix: assign properties of mutations in withMutation
1 parent 6625d07 commit dba4769

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

libs/ngrx-toolkit/src/lib/with-mutations.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,25 @@ function createMutationsFeature<Result extends MutationsDictionary>(
118118
keys.reduce(
119119
(acc, key) => ({
120120
...acc,
121-
[key]: async (params: never) => {
122-
const mutation = mutations[key];
123-
if (!mutation) {
124-
throw new Error(`Mutation ${key} not found`);
125-
}
126-
const result = await mutation(params);
127-
return result;
128-
},
121+
[key]: Object.assign(
122+
async (params: never) => {
123+
const mutation = mutations[key];
124+
if (!mutation) {
125+
throw new Error(`Mutation ${key} not found`);
126+
}
127+
const result = await mutation(params);
128+
129+
return result;
130+
},
131+
{
132+
status: mutations[key].status,
133+
value: mutations[key].value,
134+
isPending: mutations[key].isPending,
135+
isSuccess: mutations[key].isSuccess,
136+
error: mutations[key].error,
137+
hasValue: mutations[key].hasValue,
138+
},
139+
),
129140
}),
130141
{} as MethodsDictionary,
131142
),

0 commit comments

Comments
 (0)