Skip to content

The last example says it can't be written in Reselect, but it can.  #15

Closed
@todorpr

Description

@todorpr

I just discovered proxy-memoize recently I think it has a good potential.

One thing I think is incorrect is the statement that the last example can't be written in reselect

The last example is this one:

const todoTextsSelector = memoize(state => state.todos.map(todo => todo.text));

Here is how I see it in reselect:

const state = {
  todos: [{ text: 'aaa' }, { text: 'bbb' }]
}

const todoTextSelector = createSelector(
  state => state.todos,
  todos => todos.map(todo => todo.text)
)

console.log(todoTextSelector(state)) // ["aaa", "bbb"]
console.log(todoTextSelector(state)) // ["aaa", "bbb"]
console.log(todoTextSelector(state)) // ["aaa", "bbb"]
console.log(todoTextSelector(state)) // ["aaa", "bbb"]
console.log(todoTextSelector.recomputations()) // 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions