-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Fabien JUIF
committed
Jul 17, 2017
1 parent
b4d806d
commit 88d92ed
Showing
18 changed files
with
324 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Types | ||
|
||
- [map](#map) | ||
- [uniq](#uniq) | ||
|
||
## map | ||
### state | ||
```es6 | ||
{ | ||
data: { <key1>: <instance1>, <key2>: <instance2> }, | ||
array: [<instance1>, <instance2>], | ||
keys: [<key1>, <key2>], | ||
initialized: true, | ||
|
||
} | ||
``` | ||
|
||
### actions | ||
|
||
| function name | description | signature | generated action | | ||
|---|---|---|---| | ||
| `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> }` | | ||
| `update` | update an existing instance of your resource | `update(<instance>)` | `{ type: '@trampss/UPDATE_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' }` | | ||
|
||
### selectors | ||
|
||
| signature | description | comment | | ||
|---|---|---| | ||
| `get(<id>)(state)` | returns all data, or specific one(s) (by key(s)) | <ul><li>if `<id>` is `undefined`, it returns all data</li><li>if `<id>` is an array, it returns all instances that match one of the ids</li><li>in other cases, it returns the instance which `id` matches the parameter</li></ul> | | ||
| `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) | | | ||
| `getLength(state)` | returns number of stored instances | | | ||
| `isInitialized(state)` | returns true if the store has been initialized (by `add` or by `set` action) | | | ||
| `getState(state)` | returns the global state of your reducer | | | ||
|
||
## uniq | ||
### state | ||
```es6 | ||
{ | ||
data: <instance>, | ||
initialized: true, | ||
} | ||
``` | ||
|
||
### actions | ||
|
||
| function name | description | signature | generated action | | ||
|---|---|---|---| | ||
| `set` | set the instance | `set(<instance>)` | `{ type: '@trampss/SET_TODOS', payload: <instance> }` | | ||
| `reset` | reset the reducer (wipe all data) | `reset()` | `{ type: '@trampss/RESET_TODOS' }` | | ||
|
||
### selectors | ||
|
||
| signature | description | comment | | ||
|---|---|---| | ||
| `get()(state)` | returns data (instance) | | | ||
| `isInitialized(state)` | returns true if the store has been initialized (by `set` action) | | | ||
| `getState(state)` | returns the global state of your reducer | | |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.