@segment/create-selector
v0.0.4
Published
[![Circle CI](https://circleci.com/gh/segmentio/create-selector.svg?style=svg&circle-token=44d8c416a1100b6ad5ce54061d559f7a9bd73621)](https://circleci.com/gh/segmentio/create-selector)
Downloads
60
Maintainers
Keywords
Readme
create-selector
A simple wrapper over reselect to allow creating selectors with a cache size more than 1. See here for more information on this.
Example
import createSelector from '@segment/create-selector'
const getVisibilityFilter = (state) => state.visibilityFilter
const getTodos = (state) => state.todos
export const getVisibleTodos = createSelector(
[ getVisibilityFilter, getTodos ],
(visibilityFilter, todos) => {
switch (visibilityFilter) {
case 'SHOW_ALL':
return todos
case 'SHOW_COMPLETED':
return todos.filter(t => t.completed)
case 'SHOW_ACTIVE':
return todos.filter(t => !t.completed)
}
}
)
Developing
$ goto create-selector
$ make test
Releasing / Publishing
CircleCI will handle publishing to npm. To cut a new release, just do:
$ git changelog --tag <version>
$ vim package.json # enter <version>
$ git release <version>
Where <version>
follows the semver spec.