Fork me on GitHub

I’m trying the simple example app at 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 ( 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.


@p-himik Thanks! So things are working as I expect now.


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 think that's just that, yeah.


You also probably need to know about defonce in this context.


OK, yes. Cool; thanks again.


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 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.


Ah, you are probably asleep. I’ll create the PR.


Yes, I had a quick look. It looks the same as the “simple” example.


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.


you should always do authentication / authorization server-side


you can never depend on the front-end to be truthful

✔️ 8

e.g. sensitive data should be behind an API that uses an authorization mechanism to determine if the user can see it