Skip to content

Instantly share code, notes, and snippets.

@rupeshtiwari
Created June 23, 2017 12:16
Show Gist options
  • Save rupeshtiwari/79ba7dae78459cb2d895ae1584fb550a to your computer and use it in GitHub Desktop.
Save rupeshtiwari/79ba7dae78459cb2d895ae1584fb550a to your computer and use it in GitHub Desktop.
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