Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasz-pluszczewski committed Dec 14, 2017
1 parent b6e5bd0 commit f5e2874
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@ This library is in early stage of development. Currently there is only one well
- **delimiter**: *string* (defaut: **'.'**) delimiter used in the path
- returns **newObject**

## Usage example
Imagine [reducer](https://redux.js.org/docs/basics/Reducers.html):
```javascript
case MY_FANCY_ACTION
return {
...state,
fieldOne: {
...state.fieldOne,
fieldTwo: {
...state.fieldTwo,
fieldThree: 'foo',
},
},
};
```

With prefect-immutable you can
```javascript
import { set } from 'perfect-immutable';

case MY_FANCY_ACTION
return set(state, 'fieldOne.fieldTwo.fieldThree', 'foo');
```

## FAQ
#### Why this exists?
There are a lot of Immutable.js-like libraries, but they all force you to use immutable specific objects (like Map) and you cannot use their methods on normal JavaScript objects. That's not a problem when you're starting new project and decide to use e.g. Immutable.js but what if the app is already there, and you want immutable tools?
Expand Down

0 comments on commit f5e2874

Please sign in to comment.