From ff7d972c904660fbe6e1f0094bbffc22e390f055 Mon Sep 17 00:00:00 2001 From: Shin Suzuki Date: Wed, 14 Mar 2018 09:54:02 +0900 Subject: [PATCH] [docs] [reducers] Add power-assign to ImmutableUpdatePatterns --- .../reducers/ImmutableUpdatePatterns.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/recipes/reducers/ImmutableUpdatePatterns.md b/docs/recipes/reducers/ImmutableUpdatePatterns.md index f865988658..e66e83cdc9 100644 --- a/docs/recipes/reducers/ImmutableUpdatePatterns.md +++ b/docs/recipes/reducers/ImmutableUpdatePatterns.md @@ -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). \ No newline at end of file +[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). +