Skip to content

Commit 4032358

Browse files
committed
fix: reassign mutation whole, rather than subset of props
1 parent 08f4ba3 commit 4032358

1 file changed

Lines changed: 9 additions & 16 deletions

File tree

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

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,25 +118,18 @@ function createMutationsFeature<Result extends MutationsDictionary>(
118118
keys.reduce(
119119
(acc, key) => ({
120120
...acc,
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-
}
121+
[key]: (() => {
122+
const mutation = mutations[key];
123+
if (!mutation) {
124+
throw new Error(`Mutation ${key} not found`);
125+
}
126+
127+
return Object.assign(async (params: never) => {
127128
const result = await mutation(params);
128129

129130
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-
),
131+
}, mutation);
132+
})(),
140133
}),
141134
{} as MethodsDictionary,
142135
),

0 commit comments

Comments
 (0)