This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-28
Channels
- # announcements (1)
- # aws (1)
- # babashka (41)
- # beginners (21)
- # biff (7)
- # calva (102)
- # cider (8)
- # cljs-dev (1)
- # clojure (8)
- # clojure-bay-area (2)
- # clojure-dev (30)
- # clojure-europe (40)
- # clojure-norway (52)
- # clojure-sweden (9)
- # clojure-uk (5)
- # clojurescript (15)
- # cursive (7)
- # data-science (1)
- # datomic (23)
- # events (1)
- # fulcro (9)
- # humbleui (23)
- # hyperfiddle (46)
- # introduce-yourself (1)
- # jackdaw (2)
- # jobs (2)
- # london-clojurians (1)
- # malli (13)
- # off-topic (8)
- # re-frame (36)
- # remote-jobs (1)
- # shadow-cljs (4)
- # specter (4)
- # squint (1)
- # transit (4)
- # vim (1)
Regarding the new “flow” concept https://day8.github.io/re-frame/Flows/#cleanup Mentions that the default cleanup dissoc’s the path. This seems like a destructive default to me if I’m reading it correctly. If you’re path is nested a bit, dissoc of the whole thing could take out a lot of the db you didn’t intend. Or does dissoc only happen on the last segment of the path?
I know this can be overridden either way. Just pointing out I’d have to be defensive against the default in typical usages depending on what “dissoc the path” means.
I don't think that makes sense. If someone says I'm going to delete this path on your disk: /archive/foo/bar/baz
, would you think they are deleting /archive
as well?
I think if it says they are dissocing that path, they are dissocing that path - not the parent, grandparent, etc of that path.
No need to doubt when you can check: • https://github.com/day8/re-frame/blob/master/src/re_frame/flow/alpha.cljc#L41 • https://github.com/day8/re-frame/blob/master/src/re_frame/flow/alpha.cljc#L41
So then I was wrong (sorry mike), because it cleans up other paths than the one specified going up to the root (but only if they would be empty). I could see how it would be useful, but still seems dangerous as a default. What if someone has a sorted map or something that would not get automatically re-initialized correctly with assoc-in, update-in, etc.
Part of why I didn’t just read the source was to point out the ambiguity of it in the docs. Forgot to mention that. But thanks for the input. I think this “deep merge” is better than blindly removing the whole path. I agree with @U08JKUHA9 that it’s still a bit more aggressive than I’d expect from a default. The sorted collection situation is a good example of why
Yeah, I'm not satisfied with how it is in the docs. I haven't thought of a description that's both specific and concise enough. Maybe I'll just link to the https://github.com/day8/re-frame/blob/master/src/re_frame/utils.cljc#L85C50-L85C50. What do yall think of the https://github.com/day8/re-frame/blob/master/src/re_frame/utils.cljc#L85C50-L85C50?
Some prior art, quite a bit more concise: https://github.com/plumatic/plumbing/blob/master/src/plumbing/core.cljc#L71-L73
Yea the docstring seemed too verbose, that is better. I also think the name is wrong - it isn't deep. If anything, it is shallow, but that is probably confusing.
At the top that same file we also have a dissoc-in function: https://github.com/day8/re-frame/blob/master/src/re_frame/utils.cljc#L5-L18
I remember looking at dissoc-in and passing it up for some reason. It passes the same tests, though. Maybe that reason is gone.
I'm missing something about the startup of re-frame. The template app I started with has this:
(defn dev-setup []
(when config/debug?
(println "dev mode")))
(defn ^:dev/after-load mount-root []
(re-frame/clear-subscription-cache!)
(let [root-el (.getElementById js/document "app")]
(rdom/unmount-component-at-node root-el)
(rdom/render [views/starter] root-el)))
(defn init []
(re-frame/dispatch-sync [::events/initialize-db])
(dev-setup)
(mount-root))
But when I reload the app page, it seems ::events/initialize-db
isn't fired. I don't see it in the re-frame-10x interface, and the db there also shows empty. My app shows an empty page as a result. I would kind of expect the event to fire, or else for the db to be left as-is after the page reload. What am I missing?:builds
{:app
{:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules
{:app {:init-fn heedyapp.core/init}}
:devtools
{:preloads [day8.re-frame-10x.preload
;re-frisk.preload
]}
Just to double-check:
• Are you building the :app
build?
• Is that namespace in the first message indeed heedyapp.core
?
If the answers are "yes", then two things to do:
• Check the JS console for errors, see what's in there
• Print something in the init
and make sure it's printed in the console
And just to show the println
(defn init []
(re-frame/dispatch-sync [::events/initialize-db])
(println "you've called INIT!")
(dev-setup)
(mount-root))
if you have a separate events ns
that contains that event, is it required in your core
ns?
Ah, wait. IIRC, re-frame-10x will start showing any content only after you open it and initiate some event (any event) after that.
oh good thinking that is true
This bug looks very similar to what I see. I tried the "pop out" button and everything populates. https://github.com/day8/re-frame-10x/issues/264
That's a difficult thing to fix. I'm just thinking of a workaround, though. Maybe 10x could optionally dispatch a no-op event to the client re-frame at this time.
Okay, you can try including the closure-define day8.re-frame-10x.init-event? true
to try out this workaround. See how the example project does it:
https://github.com/day8/re-frame-10x/blob/071448858cc9a4e22ac2a1adf8e2e1b48d2ec775/examples/todomvc/shadow-cljs.edn#L32