@lilactown thanks!
when do you deref? do you wait until you absolutely need to, or do you do it as soon as you possibly can?
initially i was derefing as soon as i could, but then i found i was losing track of when i had an atom coming into a function, and when i had its contents
Usually you want to deref as close to the actual usage as possible to avoid any updates of the parent components. Note that if your ratom is actually a re-frame sub, then you should not deref it in a callback or event handler function. You have to deref it exactly inside the body of the component. Otherwise, there will be a memory leak.
oh wow, thanks. so dereferencing to get the value also marks a function for update inspection?
Not just any function but a view component, yes. And you also pass that value down a chain of components - they will all be updated if the value changes.
thanks
i'm considering using 2 identifiers, like maybe state-atom
and state
, but that ... idk, seems kinda meh. i feel like there's probably a good heuristic i'm missing.
re-com has a deref-or-value
function for that that's just used on almost every input value.
that seems worse
I disagree - when you only read from atoms, it's nice if you don't even need to remember if you have to pass a ratom or a value somewhere.
re-com splits reading and writing - usually the corresponding arguments are :model
and :on-change
.
thanks!
the code could also just leave the atom alone until its actually grabbing something out of the map inside the atom
"you" as in the whole channel, not just lilactown
does anyone know of a way to display EDN data with folding, max length for arrays etc in the browser? Iām using reagent
@smith.adriane adding reader functions is easy!
(read-string {:readers {'crux/id identity}}
"{:id #crux/id \"hello\"}")
(obviously you might want to change identity to something proper, if you expect it to actually do something more useful than just returning whatever it is)
btw for "generic EDN" may be a good idea use :default
(clojure.edn/read-string
{:default tagged-literal}
"#any :litteral")
cool. the demo no longer chokes on tagged literals and will print parse errors should they occur. thanks for the tips!
how large is your edn data? I've been working on https://blog.phronemophobic.com/treemap/treemaps-are-awesome.html for medium to largish data
looks cool, thanks for sharing!
@smith.adriane when I try to load some test edn data I get Uncaught SyntaxError: JSON.parse: expected property name or '}' at line 1 column 2 of the JSON data
ok, I don't have any error printing on the deployed demo, but i'm getting:
No reader function for tag object
when I try it locallyit works when I get rid of the #object
tagged objects