These are chat archives for ramda/ramda
in my example I am storing the id of currently selected note, so I need to fetch it when rendering the note body/title editor
also I need to traverse the graph, with previous and next elements, when arrow keys are pressed.
I just realised that this is pretty much the exact description of a Zipper type, which is a data structure that acts like a cursor and is used to walk around another data type like your tree, keeping track of the "current" node and allowing immutable updates, etc.
Function composition pattern: is there some concept of passing context to composed functions?
a(b(c(1))) === compose(a,b,c)(1) a(b(c(1, ctx), ctx), ctx) === ???
one solution I could think of was
const fnWithCtx = map(partialRight(_.__, ctx) , a,b,c) apply(compose, fnWithCtx)
I have a feeling that, this has a better solution already. @scott-christopher what say you?
zippalibrary, but it looks good at a quick glance.
cursor.toForest()to get the data out.
I suspect your state could simply become the cursor, where you'll then need to recursively map the nodes around the current item.
"recursively map the nodes around the current item." didn't get last bit.
renderParents( cursor.parents, renderNodes(cursor.before), renderFocused(cursor.content(), cursor.children()), renderNodes(cursor.after) )