Skip to content

Commit

Permalink
Merge pull request #34 from treasure-data/issues/33
Browse files Browse the repository at this point in the history
Added additional context to example docs
  • Loading branch information
bvaughn committed Jan 20, 2016
2 parents 5b580fb + d341c85 commit 48d5849
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ const rootReducer = combineReducers({
const store = compose(
applyMiddleware(...yourMiddleware),
reduxSearch({
// Configure redux-search by telling it which resources to index for searching
resourceIndexes: {
// Search configuration here (eg. search all Books by :title and :author)
// In this example Books will be searchable by :title and :author
books: ['author', 'title']
},
// This selector is responsible for returning each collection of searchable resources
resourceSelector: (resourceName, state) => {
// Resource selector here (eg. get books collection)
// In our example, all resources are stored in the state under a :resources Map
// For example "books" are stored under state.resources.books
return state.resources.get(resourceName)
}
})
Expand All @@ -74,6 +77,10 @@ import { connect } from 'react-redux'
import { createSelector } from 'reselect'
import { createSearchAction, getSearchSelectors } from 'redux-search'

// :books is a map (Object or Immutable.Map) with ids as keys
// These ids correspond to :result returned by getSearchSelectors('books')
const books = state => state.getIn(['resources', 'books'])

// :text is a selector that returns the text Books are currently filtered by
// :result is an Array of Book ids that match the current seach :text (or all Books if there is no search :text)
const {
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { createSelector } from 'reselect'
import { getSearchSelectors } from 'redux-search'

const { text, result } = getSearchSelectors('books')
const books = state => state.getIn(['resources', 'books'])

const selectors = createSelector(
[result, books, text],
Expand Down

0 comments on commit 48d5849

Please sign in to comment.