Created
June 23, 2017 12:16
-
-
Save rupeshtiwari/79ba7dae78459cb2d895ae1584fb550a to your computer and use it in GitHub Desktop.
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
var a = { | |
selectedPath: [], | |
nodes: [{ | |
title: 'core', | |
path:['nodes',0], | |
selected: false, | |
tabIndex: -1 | |
}, | |
{ | |
title: 'core', | |
path:['nodes',1], | |
selected: false, | |
tabIndex: -1 | |
} | |
] | |
} | |
const selectedPath = ['nodes',0]; | |
const selectedLens = lensPath(selectedPath); | |
//hasSelectedPath:: object -> bollean | |
const hasSelectedPath = compose(not,isEmpty, prop('selectedPath') ) | |
console.log(hasSelectedPath(a)); | |
//updateNode :: Object -> f Object | |
const toggleNode = evolve({ | |
selected: not, | |
tabIndex: add(-1) | |
}); | |
const toggleSelectedPath = over(selectedLens, toggleNode); | |
toggleSelectedPath(a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment