This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
What would be the best way to add data to the rewrite-clj zipper tree (eg. a flag per-node)?
Will the zipper then maintain all that information "correctly" though ? At the bottom there must be operations constructing nodes, this will only work if they're doing a merge or something?
@U63D7UXJB if you maybe describe your end goal, i.e. why you feel you need to flag, then maybe we could come up with more ideas. I tend to reach for the zip API, @U04V15CAJ tends to walk the nodes directly.
Basically I was writing a specialized edn editor (all the way back to formatted text), so theres extra state, and I want it to be "stable" under moving nodes, deleting them etc. Rewrite-clj helps me map changes in edn back to changes in (a whitespace-preserving string), but I want my UI state tagged back and stable too. One way I thought was to annotate each node with an ID, then I have two relationship (str->edn) (edn->id) and it's all good, but that will only work if rewrite-clj is happy to maintain e,tea I formation per zipper node
I could also try not using the zipper, I haven't thought it through, I don't think I need to accumulate multiple changes so that efficiency element of zippers is irrelevant
I have some time later today to play around. I can't remember if assoc on a node would be problematic when using the zip api.
A concrete example: I have an edn list of strings, in my app runtime that corresponds to a UI component for each string, with state like text-cursor, I perform an operation like deleting one of the strings, now those strings all have different indexes in their parent list, but on my rerender pass I need to tie back to component state per-string the paths are broken so I need IDs