Applying several filters using Redux Selectors and Reselect, what is better?

152 Views Asked by At

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:

  1. How do I do it using Redux Reselect library?
  2. 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)));
    }
  1. Can I just make a Class and define all three filters as a Class methods to chain them like this? (Is it a good idea to use Classes outside main react Component logic?)
   const resultData = Data.filter1().filter2().filter3()
0

There are 0 best solutions below