Skip to content

Conversation

@naw
Copy link

@naw naw commented Nov 6, 2015

Meant to be similar to reselect's createSelector, but instead of
reaching into redux state, it reaches into the component's this.

@jgautsch I tried to make reselect work inside the component, but reselect expects inputSelectors, which are functions that map state to inputs, and then pass those inputs to the transformation function.

Instead, we need to be able to map things already inside the component (such as this.props.something or this.someOtherDerivedData) into inputs that are passed to the transformation function.

There might be a way to clean up the API a little, but for now, it's pretty similar to reselect.

Meant to be similar to reselect's `createSelector`, but instead of
reaching into redux `state`, it reaches into the component's `this`.
@naw
Copy link
Author

naw commented Nov 6, 2015

@jgautsch I added a "search" feature to the basic todo app in order to demonstrate composition of derived data.

visibleTodos are todos that match the visibility filter (i.e. completed, uncompleted, or all)

matchingTodos are visibleTodos that also match the text search string.

When you change the text search, matchingTodos() is recalculated (by filtering visibleTodos), but visibleTodos does not have to be recalculated --- it just uses the memoized result.

When you add a new todo, you have to recalculate the visibleTodos(), which also triggers matchingTodos() to be recalculated, since it depends on visibleTodos().

@naw
Copy link
Author

naw commented Nov 6, 2015

webpack can't seem to compile this since I moved it into its own repo. Not sure off hand why, probably something with ES6 vs ES7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants