Skip to content

Commit

Permalink
Feature: (getMany)
Browse files Browse the repository at this point in the history
1.) Breaking change to API
2.) added getMany
  • Loading branch information
millsky committed Apr 20, 2018
1 parent d36ed0e commit 109e405
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ const currentState = {
}
// create getter and setter pairs for every property
const ourSpecialLens = lenscrafter(initialState);
ourSpecialLens.someNestedValue.get(/* state */); // 1
ourSpeicalLens.someNestedValue.get(currentState); // 'New Value'
ourSpecialLens.props.someNestedValue.get(/* state */); // 1
ourSpeicalLens.props.someNestedValue.get(currentState); // 'New Value'
```
using this method, the state retrieval process can be simplified into the one liner above.
It can be ensured that when getting state, a value will always be returned as a fallback instead of `undefined`.
Expand All @@ -93,21 +93,27 @@ It can be ensured that when getting state, a value will always be returned as a

### Usage

#### ```newLens.property.get(object)```:
#### ```newLens.props.property.get(object)```:
`object`: The object that the property should be retrieved for. If the object does not have the property it will fallback to the value of the property in the initial call to `lenscrafter`.

Returns the current value of the object at the specified property

#### ```newLens.property.set(value, object)```:
#### ```newLens.props.property.set(value, object)```:
`value`: The value to set the property to.

`object`: The object for which the value should be set.

Returns a new object with the specified property updated to the specified value

#### ```newLens.property.lens```:
#### ```newLens.props.property.lens```:
Returns the lens used for getting and setting, this is useful for further composition.

### ```newLens.getMany(propsArray, object)```

`propsArray: Array<string>`: An array of properties to get the value of

`object`: The object for which the values should be retrieved

# Installation

To install: `npm install --save lenscrafter`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lenscrafter",
"version": "0.0.4",
"version": "1.0.4",
"description": "A Micro Library for immutable and safe state access",
"main": "index.js",
"jsnext:main": "src/index.js",
Expand Down

0 comments on commit 109e405

Please sign in to comment.