NGRX Traits is a library to help you compose and reuse state logic in your angular app. There is two versions, @ngrx-traits/signals supports ngrx-signals, and @ngrx-traits/{core, common} supports ngrx.
MIT License
44
stars
3
forks
source link
withCalls typedCallConfig that has a no resultProp and a call with no parameters doesnt generate the correct types #74
The following code should generate a property called testCallResult but it doesn't, and also damages the previous function types removing them from the store.
const Store = signalStore(
withState({ foo: 'bar' }),
withCalls((store) => ({
testCall: typedCallConfig({
call: () => {
return of(true);
},
onSuccess: (result) => {
// patchState should be able to update the store inside onSuccess
patchState(store, { foo: result });
},
onError,
}),
})),
);
As a workaround you can omit using typedCallConfig and use an object for the config but that loses the type for the result on the onSuccess method
The following code should generate a property called testCallResult but it doesn't, and also damages the previous function types removing them from the store.
const Store = signalStore( withState({ foo: 'bar' }), withCalls((store) => ({ testCall: typedCallConfig({ call: () => { return of(true); }, onSuccess: (result) => { // patchState should be able to update the store inside onSuccess patchState(store, { foo: result }); }, onError, }), })), ); As a workaround you can omit using typedCallConfig and use an object for the config but that loses the type for the result on the onSuccess method