RFC: Simplified reducer method
Opened this issue · 2 comments
rainerhahnekamp commented
The on
method can accept the patched state as return type of the reducer function.
At the moment, it goes like this:
reducer(actions, on) {
on(actions.flightsLoaded, (state, {flights}) => patchState(state, {flights})));
}
The new version could look like this:
reducer(actions, on) {
on(actions.flightsLoaded, (, {flights}) => ({flights}))
}
Or if the state doesn't require the payload:
reducer(actions, on) {
on(actions.resetSearch, {flights: []})
}
rosostolato commented
This would work with the proposal of #8.
It could allow you to use the same createReducer
from @ngrx/store
. Just like this approach:
https://github.com/rosostolato/ngrx-signals-redux/blob/master/src/app/state/posts/posts.reducer.ts
https://github.com/rosostolato/ngrx-signals-redux/blob/master/src/app/state/posts/posts.store.ts
rainerhahnekamp commented
So #8 is about adding a dependency to @ngrx/store. This is here is about the native version which only requires the Signal Store as dependency.