Changelog
v3.0.0 - 2017/03/24
Performance improvements (thanks to @johnhaley81)
Updated Typescript typings (thanks to everyone who helped)
For performance reasons, a selector is now not recalculated if its input is equal by reference (===
).
import { createSelector } from 'reselect'
const mySelector = createSelector(
state => state.values.filter(val => val < 5),
values => {
console.log('calling..')
return values.reduce((acc, val) => acc + val, 0)
}
)
var createSelector = require('./dist/reselect.js').createSelector
const mySelector = createSelector(
state => state.values.filter(val => val < 5),
values => {
console.log('calling..')
return values.reduce((acc, val) => acc + val, 0)
}
)
var state1 = { values: [1, 2, 3, 4, 5, 6, 7, 8, 9] }
console.log(mySelector(state1))
state1.values = [3, 4, 5, 6, 7, 8, 9]
console.log(mySelector(state1))
var state2 = { values: [1, 2, 3, 4, 5, 6, 7, 8, 9] }
console.log(mySelector(state2))
var state3 = { values: [3, 4, 5, 6, 7] }
console.log(mySelector(state3))