This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-17
Channels
- # aws (3)
- # beginners (104)
- # boot (11)
- # calva (3)
- # clj-kondo (1)
- # cljdoc (6)
- # cljs-dev (23)
- # cljsrn (1)
- # clojure (144)
- # clojure-dev (54)
- # clojure-europe (6)
- # clojure-italy (2)
- # clojure-nl (26)
- # clojure-spec (6)
- # clojure-sweden (1)
- # clojure-uk (13)
- # clojurescript (38)
- # core-async (9)
- # cursive (14)
- # data-science (3)
- # datascript (22)
- # datomic (17)
- # figwheel (1)
- # fulcro (4)
- # graphql (6)
- # hoplon (59)
- # jackdaw (2)
- # jobs (6)
- # jobs-discuss (44)
- # juxt (14)
- # leiningen (1)
- # luminus (3)
- # nrepl (3)
- # off-topic (12)
- # re-frame (24)
- # reagent (7)
- # reitit (7)
- # rewrite-clj (1)
- # schema (1)
- # shadow-cljs (37)
- # spacemacs (4)
- # sql (25)
- # testing (12)
- # tools-deps (11)
- # utah-clojurians (1)
Hello, I’m using shadow-cljs to build a reagent + re-frame app. What should I call during development in the :after-load function so that all components would be re-rendered with the changes in the code? I have tried calling (r/render [main-view] (.getElementById js/document "app"))
again in that function and reagent.core/force-update-all
, but the changes don’t seem to appear in the browser. Sorry if it’s more of a reagent question.
hey. the issue isn't reagent its re-frame. I can't remember the exact name but something like (re-frame.core/clear-subscription-cache!)
or so (in the after-load)
(defn ^:dev/after-load start
[]
(r/render [app]
(.getElementById js/document "app")))
(defn ^:export init
[]
(router/start!)
(rf/dispatch-sync [:initialise-db])
(start))
Thank you. I’ll take a look in that function and return with my findings then 🙂
That didn’t seem to work 😕 Maybe I have done something wrong elsewhere.
@juholei look at the browser console. shadow-cljs tells you what it is doing. if all that looks in order your code might be doing stuff that can't be hot-reloaded properly
Yeah the after-load function gets called correctly with shadow-cljs and re-frame subscriptions and events get their changes loaded correctly, so I guess I have something wrong with my views somewhere.
if you keep references to potentially reloaded code in the state somewhere this can be the problem
Yeah it might be just that. I just noticed if I make changes to my front end routing related files (using reitit), then the changed views also update. And reitit puts a reference to the current view component to the app state, so seems like that may be the problem. Thanks for your help 🙂
Hey all, I am playing around with the :release
portion of my shadow-cljs project and have noticed that the released artifacts are trying to connect to
. I'm not sure why this is required and if not was wondering how to disable this, any ideas?
it looks like your build has the shadow-cljs development stuff included. are you sure you’re running your release code?
make sure you are loading the correct output files. by default those will be the same as your development files so you might have something cached if the server doesn't handle that properly
Okay, currently I am outputting the release
'd files to a different location than the dev
's, however, I can take a look at the caching, that might be the issue
you can easily tell if you are loading the actual release build by the size and number of requests made
That's a good point, I'll dig in there
Curiosity question: how does shadow implement hot reloading? It doesn't say what library it uses in the manual https://shadow-cljs.github.io/docs/UsersGuide.html#_hot_code_reload
@teawaterwire what do you mean by library? shadow-cljs handles the reloading stuff, no library used
as far as the reloading is concerned it is pretty trivial to do given that everything is evaled in the same scope and namespaced
so unlike regular JS we can manipulate that scope easily and just replace definitions on the fly
oh I see - sweet! Everybody's talking about figwheel but Shadow is actually doing hot reloading on its own as well 🙂
(sorry I was under the impression that Shadow used a library underneath - I was wrong 😄 )
interesting! So many goodies included in Shadow 🌟
Hi. Is there an example of smooth development workflow with service worker? Say I want to build main.js and service-worker.js. They should be independent: if service-worker.js recompiles main.js shouldn't reload and vice versa. If service-worker.js changes browser should be notified to run unregister/register code.
I typically recommend using something like https://developers.google.com/web/tools/workbox/ for service workers
Most simple thing like
{:main {:entries [foo.core]}
:service-worker {:entries [foo.sw]
:depends-on #{:main}
:web-worker true}}
kinda "works" because there is reload notification in a browser when code in foo.sw
is updated. Of course nothing happens because service-worker.js is not included in a page. But at least there is a hope to hook into (defn handle-message [{:keys [type] :as msg}]
or smth like that and run unregister/register code for service-worker. msg
map has all info to get to know when foo.sw
is recompiled.service workers are kinda special so I would probably make a separate build for them
Thanks, I didn't think about repl