As noted by Kalle on the discord with the new release of ImmerJS, you can now use it correctly with Aurelia store. In a nutshell:
- Disable auto-freeze with
setAutoFreeze(false);
- Write your actions like this:
export const selectBackend = produce((state: State, selectedBackend: SelectableBackend) => {
state.selectedBackend = selectedBackend;
});
- Only modify the state directly: immer will track its modification to create a new object but won’t modify the existing one. If you modify any other parameter directly, it will be mutated.
If you need more details, I wrote a detailed blog post.