Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+6 added−5 removed
other:+6 added−5 removed
Provenance
Commit
58e9b57
Tree
5863670
Author
Michel Weststrate <mweststrate@gmail.com>
Committer
Michel Weststrate <mweststrate@gmail.com>
Parent
553299f
1 file changed+6 added−5 removed
modified:readme.md+6 added-5 removed
3 unmodified lines
4
5
6
7
8
8
9
10
10
11
12
13
12
13
14
15
16
17
17
18
19
20
21
22
23
160 unmodified lines
Expand all
3 unmodified lines
---
Immer (German for: always) is a tiny package that allows you to work with immutable state in a more convenient way.
It is based on [_copy-on-write_](https://en.wikipedia.org/wiki/Copy-on-write) mechanism.
It is based on the [_copy-on-write_](https://en.wikipedia.org/wiki/Copy-on-write) mechanism.
The basic idea is that, you will apply all your changes to a _draftState_, which is a proxy of the _currentState_ and once all your mutations are completed, immer will produce the _nextState_ based on the mutations to the draft state. This means that you can interact with your data by simply modifying it, while keeping all the benefits of immutable data.
The basic idea is that you will apply all your changes to a temporarily _draftState_, which is a proxy of the _currentState_.
Once all your mutations are completed, immer will produce the _nextState_ based on the mutations to the draft state.
This means that you can interact with your data by simply modifying it, while keeping all the benefits of immutable data.
<center>

Using immer is like having a personal assistant; he takes a letter (the current state), and gives you a copy (draft) to jot changes onto. Once you are done, the assistant will take your draft and produce the real immutable, final letter for you (the next state).
</center>
A mindful reader might notice that this is quite similar to `withMutations` of ImmutableJS. It is indeed, but generalized and applicable to plain, native JavaScript data structures (arrays and objects) without further needing any library.