Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 43 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,49 @@ npm install --save feathers-action-react

```js
import { connect } from 'feathers-action-react'
import {
createSelector,
createStructuredSelector
} from 'reselect'

import Dogs from '../components/dogs'

import { actions as dogActions } from '../'

import { getIndexProps } from '../getters'
import { getDogs, getCollars } from '../getters'

export default connect({
selector: getIndexProps,
actions: { dogs: dogActions },
query: {
service: 'dogs',
params: {}
}
selector: createStructuredSelector({
dogs: getDogs,
collars: getCollars
}),
actions: {
dogs: dogActions
},
query: [
{
name: 'findAllDogs',
service: 'dogs',
params: {}
},
{
name: 'findCollarsForEachDog',
service: 'collars',
dependencies: [
'findAllDogs'
],
params: createSelector(
getDogs,
(dogs) => ({
params: {
dogId: {
$in: dogs.map(dog => dog.id)
}
}
})
}
}
]
})(Dogs)
```

Expand All @@ -37,12 +66,14 @@ export default connect({

`options`:

- `selector`: a function of shape `(state) => props`
- `selector`: a function of shape `(state, props) => selected`
- `actions`: an object where keys are feathers service names and values are objects of action creators
- `query`: an object to describe a feathers `find` or `get` service method call, or an array of these, or a function of shape `(props) => query`.
- for find: `{ service, params }`
- for get: `{ service, id, params }`
- `shouldQueryAgain`: a function of shape `(props, status, prevProps, prevStatus) => Boolean` for whether we should re-fetch on updated props
- `query`: an object or array of objects to describe feathers `find` or `get` service method calls
- `name`: (optional) name of query
- `service`: (required) name of feathers service to call
- `dependencies`: (optional) array of query names that this query depends on being run before is ready
- `params`: (optional) object or selector for object to use as `params` argument in feathers call
- `id`: (required if `get` call) value or selector for value to use as `id` argument in feathers call

`hoc` is a "higher-order component": a function of shape `(component) => nextComponent`

Expand Down
Loading