This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-27
Channels
- # announcements (1)
- # babashka (7)
- # beginners (60)
- # calva (24)
- # cider (2)
- # cljdoc (9)
- # clojure (21)
- # clojure-australia (1)
- # clojure-europe (2)
- # clojurescript (26)
- # core-async (89)
- # datalog (11)
- # datomic (40)
- # fulcro (24)
- # graalvm (5)
- # luminus (1)
- # meander (1)
- # numerical-computing (1)
- # off-topic (3)
- # shadow-cljs (6)
- # test-check (10)
- # tools-deps (7)
- # xtdb (18)
@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.
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.
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
.
the code could also just leave the atom alone until its actually grabbing something out of the map inside the atom
does anyone know of a way to display EDN data with folding, max length for arrays etc in the browser? Iām using reagent
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
@U7RJTCH6J 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
https://github.com/djblue/portal might also be a solution
@U7RJTCH6J 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!