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.
I'd also say it isn't doing what it says in the docs (it is doing more)
@kimo741 FYI
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 @isak 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
Good catch.
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?Does anything call init?
Looks like the init-fn in shadow-cljs.edn does
How does that look?
: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
Yes and yes.
I added the console message.
Yet 10x still has no content.
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?
I guess I've done something to break 10x. This was working before.
The page acts as if the db is there.
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
Ah, well, I guess that solves the mystery for now.
Seems that that change has made re-frame-10x panel appear on every page reload.
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
I'd like to say that fixed it. It helped a little - I see the ::intialize-db in 10x when I reload the page now. But I'm noticing that 10x doesn't "see" any events unless they happen while the 10x panel is open. FWIW I upgraded to 1.9.0 yesterday.
maybe the event should dispatch when the panel opens, instead of at init time
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.
still not sure about the startup issue, though.. probably have to skip this workaround and get into the real solution