We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What about a patchState which (almost) guarantees immutability?
patchState
We might also provide an overloaded version, where the action name can be provided.
I see two options:
Readonly
The state, provided via patchStatecould be a nested readonly type.
If the state is
interface FlightState { flights: Flight[]; airline: { name: string, shortcut: string }, loaded: boolean; selectedId: number; }
Following calls of patchState would fail to compile:
patchState(state, value => value.loaded = false); patchState(state, value => value.airline.name = 'AUA'); patchState(state, value => value.flights[0].id = 1); patchState(state, value => value.flights.push({id: 1}));
The other option is to use immer.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
What about a
patchState
which (almost) guarantees immutability?We might also provide an overloaded version, where the action name can be provided.
I see two options:
Option 1: Deep
Readonly
The state, provided via
patchState
could be a nested readonly type.If the state is
Following calls of
patchState
would fail to compile:Option 2: Immer
The other option is to use immer.
The text was updated successfully, but these errors were encountered: