-
-
Notifications
You must be signed in to change notification settings - Fork 856
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added first class support for
Map
and Set
BREAKING CHANGE: Maps and Sets are treated differently now; they will no longer directly mutated when updated inside a draft This release introduces first class support for Maps and Sets! Some things to keep in mind: * Inside recipes, you can directly modify Maps and Sets with methods like `add`, `set`, `delete` and `clear` * Those methods do mutate draft Maps and Sets, but won't actually change their originals! * Immer does not polyfill Map and Set automatically in environments where those aren't available out of the box * Maps and Sets are supported both in ES5 and Proxy mode * If `autoFreeze` is enabled, the maps and sets returned from a producer will be artificially frozen by making their mutative APIs unusable * Non primitive keys for Maps, and non primitive values for Sets are supported. However, we strongly recommend to not combine non-primitive keys to Maps with patches, for reasons expressed below. Open questions * TypeScript support for storing immutable types inside Maps and Sets, and converting them to `Draft`'s, is limited, see #448 for details * Since JSON-patch standard doesn't offer support for Sets or Maps, it is not entirely clear how mutations to those are best described by patches, so this might be refined in the future. See also #450 Credits to @runnez, @aigoncharov and @aleclarson for making this happen!
- Loading branch information
Showing
33 changed files
with
2,527 additions
and
478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,4 +59,4 @@ typings/ | |
|
||
.idea | ||
dist/ | ||
website/build | ||
website/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.