Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Immutable Data With Immer

Immutable Data With Immer

Using immutable data structures provides many benefits, including making your code easier to reason about and less prone to bugs.

Vitor Alencar

February 08, 2020
Tweet

More Decks by Vitor Alencar

Other Decks in Programming

Transcript

  1. Immutable Data With Immer Using immutable data structures provides many

    benefits, including making your code easier to reason about and less prone to bugs.
  2. Immutable State Structural sharing Currying Detect and distribute changes in

    data Today we’re looking at updates and new features regarding...
  3. Using immutable data structures provides many benefits, including making your

    code easier to reason about and less prone to bugs.
  4. WHY • Immutable objects are simpler to construct, test, and

    use • Truly immutable objects are always thread-safe • They help to avoid temporal coupling • Their usage is side-effect free
  5. • Proxy root • Lazily create proxy when a field

    is dereferenced • Upon write, create shallow clone • Upon finish, combine clones, freeze the modified objects
  6. • Immutability with normal JavaScript objects, arrays, Sets and Maps.

    No new APIs to learn! • Strongly typed, no string based paths selectors etc. • Structural sharing out of the box • Object freezing out of the box • Deep updates are a breeze • Boilerplate reduction. Less noise, more concise code. • First class support for patches • Small size 6kb Benefits