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
import {get} from 'lodash' | |
let x = {a: 1, b:2} | |
// a and b is conditional key like if key == a | |
let hope = get(x, 'kkk', 'not exist'); | |
// magic is just happen not exist is appear welcome lodash |
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; |
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
export const buildReducers = (name)=>{ | |
const handlers = { | |
[`set_main_${name}`]: mainHandlers.set_main, | |
}; | |
return { | |
[name]: (state = {}, action)=>( get(handlers, action.type, d => d)(state, action)) | |
} | |
} | |
// buildReducer('app_name') |
NewerOlder