Skip to content

Commit

Permalink
Merge branch 'major' into del-remove
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien JUIF committed Jun 26, 2017
2 parents 755e5b8 + dd3e2af commit 8d22b58
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 40 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ Actions are:

| function name | description | signature | generated action |
|---|---|---|---|
| `set` | set an array of instances of your resource | `set(<array>)` | `{ type: 'SET_todos', payload: <array> }` |
| `add` | add an instance of your resource | `add(<instance>)` | `{ type: 'ADD_todos', payload: <instance> }` |
| `remove` | remove one instance of your resource by its key | `remove(<key>)` | `{ type: 'REMOVE_todos', payload: <key> }` |
| `reset` | reset the reducer (wipe all data) | `reset()` | `{ type: 'RESET_todos' }` |
| `set` | set an array of instances of your resource | `set(<array>)` | `{ type: '@trampss/SET_TODOS', payload: <array> }` |
| `add` | add an instance of your resource | `add(<instance>)` | `{ type: '@trampss/ADD_TODOS', payload: <instance> }` |
| `remove` | remove one instance of your resource by its key | `remove(<key>)` | `{ type: '@trampss/REMOVE_TODOS', payload: <key> }` |
| `reset` | reset the reducer (wipe all data) | `reset()` | `{ type: '@trampss/RESET_TODOS' }` |


Example, we set todos to our reducer:
Expand Down Expand Up @@ -156,9 +156,9 @@ Selectors are:
| `getBy(<propertyPath>, <value>)(state)` | get data specified by the field you want to filter with (take care, selectors are not memoized) | Example: `getBy('visible', true)(state)` returns all visible todos.
| `getKeys(state)` | returns all store keys (in array) | |
| `getAsArray(state)` | returns all data in array (raw) | |
| `getNb(state)` | returns number of stored instances | |
| `getLength(state)` | returns number of stored instances | |
| `isInitialized(state)` | return true if the store has been initialized (by `add` or by `set` action) | |
| `getState(state)` | returns the global state of your reducer | The global state contains :<ul><li>`data`: key/value store</li><li>`array`: raw data</li><li>`keys`: keys array</li><li>`nb`: store length</li><li>`initialized`: boolean (set to true by `set` and `add` actions)</li></ul>
| `getState(state)` | returns the global state of your reducer | The global state contains :<ul><li>`data`: key/value store</li><li>`array`: raw data</li><li>`keys`: keys array</li><li>`initialized`: boolean (set to true by `set` and `add` actions)</li></ul>

Example, we retrieve the todo with id `1`:
```es6
Expand Down
2 changes: 1 addition & 1 deletion index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "trampss-redux-data-store",
"version": "3.2.1",
"version": "4.0.0",
"main": "index.js",
"license": "MIT",
"peerDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions src/__snapshots__/actions.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
exports[`actions should trigger a remove action 1`] = `
Object {
"payload": "remove",
"type": "REMOVE_testPrefix",
"type": "@trampss/REMOVE_TESTPREFIX",
}
`;

exports[`actions should trigger a reset action 1`] = `
Object {
"type": "RESET_testPrefix",
"type": "@trampss/RESET_TESTPREFIX",
}
`;

Expand All @@ -25,7 +25,7 @@ Object {
"code": "set2",
},
],
"type": "SET_testPrefix",
"type": "@trampss/SET_TESTPREFIX",
}
`;

Expand All @@ -35,6 +35,6 @@ Object {
"an": "element_add",
"code": "add",
},
"type": "ADD_testPrefix",
"type": "@trampss/ADD_TESTPREFIX",
}
`;

0 comments on commit 8d22b58

Please sign in to comment.