Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[docs] [reducers] Add power-assign to ImmutableUpdatePatterns
  • Loading branch information
shinout authored Mar 14, 2018
commit ff7d972c904660fbe6e1f0094bbffc22e390f055
19 changes: 18 additions & 1 deletion docs/recipes/reducers/ImmutableUpdatePatterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,21 @@ var newCollection = update(collection, {2: {a: {$splice: [[1, 1, 13, 14]]}}});

They can provide a useful alternative to writing manual immutable update logic.

A list of many immutable update utilities can be found in the [Immutable Data#Immutable Update Utilities](https://github.com/markerikson/redux-ecosystem-links/blob/master/immutable-data.md#immutable-update-utilities) section of the [Redux Addons Catalog](https://github.com/markerikson/redux-ecosystem-links).
[power-assign](https://github.com/phenyl-js/phenyl/tree/master/modules/power-assign) is also a immutable updater of nested values. It follows the [MongoDB way]().

```js
var obj = {
count: 11,
arr: ['value1'],
bar: { baz: 'abc' }
};
var newObj = assign(obj, {
$inc: { count: 1 },
$push: { arr: 'value2' },
$unset: { 'bar.baz': '' }
});
```


A list of many immutable update utilities can be found in the [Immutable Data#Immutable Update Utilities](https://github.com/markerikson/redux-ecosystem-links/blob/master/immutable-data.md#immutable-update-utilities) section of the [Redux Addons Catalog](https://github.com/markerikson/redux-ecosystem-links).