I have three filtering functions In my selectors.js
file, which take state
and return filtered state
,
let's say :
filter1(state){...};
filter2(state){...};
filter3(state){...};
I need to combine them together so that the state
could go through all of them if several filters are applied simultaneously.
So I have several questions:
- How do I do it using Redux Reselect library?
- Is it a good idea to just make 4th function and call all three functions in a recursive way like this in terms of readability and best pactice?
combineFilters(state) {
return filter3(filter2(filter1(state)));
}
- Can I just make a
Class
and define all three filters as aClass
methods to chain them like this? (Is it a good idea to useClasses
outside main reactComponent
logic?)
const resultData = Data.filter1().filter2().filter3()