Created
July 21, 2021 13:22
-
-
Save mijms/4d0b1be34799837e7849767b2c48cf5f to your computer and use it in GitHub Desktop.
apply filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//// exporting your index applying function | |
import * as Filters from './main'; | |
export default function applyFilters(params={}, data, state=store.getState(), props={}){ | |
const action = get(Filters, params.key, (p, d)=>d); | |
data = action(params, data, state, {applyFilters: applyFilters, ...props}); | |
if(params.then){ | |
data = applyFilters(params.then, data, state, props); | |
} | |
return data; | |
} | |
// applyFilters({ | |
key: delay, | |
then: { | |
key: 'compare' | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///// main File Function | |
export const compare = (params, data, state, props) => { | |
return filter(data, d => (get(compareKeys, params.compare)(params.val, get(d, params.to)))) | |
} | |
export const Delayed = (params, data, state, props) => { | |
setTimeout(() => { | |
props.applyFilters(params.fun, data, undefined, props) | |
}, params.delay) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment