What is it?
ts-action-immer package contains an alternative implementation of the
on function in
ts-action that uses Immer.
Why might you need it?
If you like the action and reducer creators in
ts-action or in NgRx - which are based on those in
ts-action - and also like Immer, you might want to use this package's Immer-based
on function to create your reducers.
Install the package using npm:
npm install ts-action-immer --save
reducer function - from
ts-action - creates a reducer function out of the combined, action-specific reducers declared using the
on function creates a reducer for a specific, narrowed action and returns an object - containing the created reducer and the types of one or more action creators.
The reducer within each
on function is passed a
state that is an Immer
Draft. The reducers can either modify the draft state and return nothing or can return a new state.