This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-12
Channels
- # announcements (2)
- # bangalore-clj (4)
- # beginners (97)
- # calva (57)
- # cider (24)
- # clj-kondo (1)
- # cljdoc (4)
- # cljs-dev (8)
- # cljsrn (6)
- # clojure (27)
- # clojure-berlin (7)
- # clojure-dev (95)
- # clojure-europe (16)
- # clojure-italy (15)
- # clojure-losangeles (9)
- # clojure-nl (8)
- # clojure-spec (10)
- # clojure-uk (29)
- # clojurescript (25)
- # clojutre (2)
- # clr (6)
- # cursive (33)
- # datomic (20)
- # dirac (1)
- # duct (9)
- # fulcro (2)
- # graalvm (18)
- # jobs (5)
- # jobs-discuss (19)
- # nrepl (4)
- # nyc (1)
- # off-topic (18)
- # pathom (15)
- # re-frame (22)
- # reagent (4)
- # reitit (1)
- # rewrite-clj (9)
- # spacemacs (2)
- # xtdb (12)
I’m trying the simple example app at https://github.com/Day8/re-frame/tree/master/examples/simple Hot-reloading isn’t working for me. When I make a change, I get “compiling” and “build completed” messages, and a pop-up spinner thing in the browser, but I don’t see the changes. If I refresh the browser, I do see the changes. Any thoughts on why this might be or how to investigate?
@nomiskatz Looks like you need to add :after-load
(https://shadow-cljs.github.io/docs/UsersGuide.html#_config) to you shadow-cljs config
@malch Thanks for the suggestion. I added :after-load simple.core/run
, and now I do see the update, but I lose the state of the UI — in that example app, if I’ve entered a new value in the color field of the UI, that gets replaced with the initial value.
@nomiskatz The issue is that the run
function also resets db
by dispatching [:initialize]
. Try to refactor the rendering code and call just that in :after-load
.
And, just to check — is this how things are supposed to work? There’s not some other deeper problem that I’ve worked around?
I sometimes run into this depending on how high up the view hierarchy the component is. At the very top, yes... only a refresh will work. There’s probably something clever to be done with after-load but I don’t yet understand the hot reload well enough.
Hey @nomiskatz 👋 Sorry about that issue and thanks to all who helped. A PR with the above changes would be welcome.
@superstructor No worries. I’ll create a PR when I get a moment, but I’ll take a look at the other example app first.
Other example probably has the same issue.
@superstructor I looked into fixing hot reloading for the todomvc example, and that was a little trickier. I had to change the definition of todomvc.core/history
to use defonce
— with a def
the reloading caused things to break (the “app” element could not be found in the DOM; not sure what the root problem is there). I also removed what I think was an unnecesary use of window.onload
in the HTML.
My changes are at https://github.com/simon-katz/re-frame/commits/hot-reloading-in-example-apps.
Happy to create a PR (and will do a bit later), but if you want to have a look at what I have done first you’re welcome to.
Quick security question with re-frame
. Is it possible to modify the re-frame db maliciously. I'm trying to restrict access to content based on authentication. I see a lot of people use :authenticated true
in their app-db or reagent atom. Could that get set to true without actually talking to the server maliciously?
Or for high security pages, is it normal to push the hiccup or page from the server to make sure it's not inspectable from the source code even if they aren't authenticated if it all lives on the front end?
I guess that second question is dumb. You just leave the frontend info pretty blank, then use the API to fill it out. Front end would just have structure which isn't a security concern.