Monday, December 3, 2018

"changing" store objects in Angular Redux while not mutating state

There are a couple of ways to ensure a new object with a new pointer.

  1. the spread operator
  2. Object.Assign
  3. deep copy
  4. the "deep clone merge function" of redux.utility.ts which has a lot of wacky rules and exception cases and maybe should be avoided

 
 

Addendum 12/4/2018: Item 4 above is bad. The lodash way could serve as a replacement however:

var foo = _cloneDeep(bar);

 
 

Addendum 12/6/2018: should be cloneDeep not _cloneDeep

No comments:

Post a Comment