angular-architects/ngrx-toolkit

RFC: Simplified reducer method

Opened this issue · 2 comments

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: []}) 
}

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.