This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-05-22
Channels
- # announcements (17)
- # beginners (11)
- # biff (5)
- # calva (22)
- # cider (30)
- # clj-kondo (33)
- # clj-on-windows (20)
- # clojure (59)
- # clojure-dev (25)
- # clojure-europe (31)
- # clojure-nl (1)
- # clojure-norway (13)
- # clojure-sweden (5)
- # clojure-uk (6)
- # clojurescript (5)
- # community-development (2)
- # cursive (4)
- # datahike (5)
- # datalevin (7)
- # datomic (11)
- # emacs (8)
- # events (1)
- # gratitude (1)
- # hoplon (5)
- # hyperfiddle (1)
- # lsp (59)
- # matrix (11)
- # polylith (14)
- # portal (3)
- # practicalli (1)
- # rdf (2)
- # reitit (9)
- # releases (3)
- # rum (5)
- # yamlscript (6)
If anyone ever loses hot reloading capability with shadow-cljs, reagent components, and reitit-frontend here is a great, small article that explains what is happening and how to fix it: https://blog.valerauko.net/2022/12/03/hot-reloading-and-reitit-in-the-frontend/ I was banging my head against the wall for days thinking I had messed up my config or something before finally searching for this on a hunch. Unfortunately the reitit-frontend re-frame example uses figwheel instead so maybe it doesn't need this var
component approach.
Vars probably would make sense in the examples. It is better to store the references to the component fns instead of the fn value in app-db/atom.
The examples probably work because all code is in one file, so every change will trigger init-routes!
call and refresh the function values stored in the re-frame db. Should work even with shadow-cljs in similar case.
Ahh, interesting. Can you explain more why the ‘init-routes!’ call will be triggered on every change just because it’s in one file. So if I change my ‘routes’ in ‘router.cljs’ file, should that be reflected immediately even though it’s in a separate file and therefore ‘init-routes!’ is not called? Sorry if that’s confusing
Depends on if your routes
are defined as var... and where they are used.
But if you'd store the routing match with component fn value to atom or app-db, you would need to rerun the match logic to refresh the stored value.
Figwheel and Shadow-cljs can have diffrerences on reloading dependences namespaces, AFAIK. If you have ns a and b, and a depends on b. It can matter if a is also reloaded with you change b.
That also changes it so that if you change a, also b is reloaded even if only a was changed.
But with the regular option, changing b, should also cause a recompilation and reload because compiler needs to recompile files when their dependencies change.
If you use after-load hook to run your app init code with routes initialization, it should always call the init routes.