Fork me on GitHub

So I’m noticing that as of recently re-frame has started complaining when I do Chrome’s “Empty cache and hard reload” option. I generally make a habit of doing this while testing webapps, but now when I do it, re-frame tells me that my event handlers don’t exist. I can ‘fix’ it by doing a normal refresh, but this seems weird. Anybody experience this?


Guess I should add: It also does this when I do a “Hard reload"


I guess this is some timing issue in your code. Maybe you are registering your handlers in some async callback or delayed. And the fact that cache is cold causes this callback to fire later than usual. I would recommend to pause re-frame event processing until you register all your handlers


As far as I know, I’m registering them the normal way: require-ing the ns in core.cljs


And my handlers.cljs is simply one def (standard-middleware) and a series of register-handler


aren’t you calling dispactch in some other place, before handles.cljs code gets actually evaluated?


I didn’t think so, but that’s how it appears


I think good approach is to avoid any sideeffect in namespaces, you should implement some init! function where you setup your re-frame and then call first dispatch, this init function should be called from your core ns as a side-effect, that is the only place where you call a fn when loading ns


Hmm, I think I can do that


have to go, will be back in 30mins


No worries. Thanks for the help!


keep in mind that goog.base is requiring namespaces asynchronously, this might play a role, you are not in control when those side-effects will run


not sure I may be wrong here


It sounds legit simple_smile


Yup, that works like a champ


I’m using re-frame with pushy (which uses HTML5 push state and lets me have URI’s w/out the #). If I type in a URI into the browser address bar of course that gets sent to the server where my app is served from. The server then decides it doesn’t know about the URI, which is true because its a client side URI. How do I deal with that. I presume I would need to send the requested URI back in the response map and somehow then let the client deal with re-creating app-db and routing the client back to the right place. This seems like a common scenario. Is there a pattern for this? Any examples? Am I even right in my assumptions?


this is unrelated to re-frame, this is more of a general question related to javascript SPA design


personally I would use urls with # and call it a day


I’m not familiar with HTML5 push state in detail, but I guess there could be some way how to prevent browser from requesting a new page on url change


also I think that you can just setup your server to always serve base app on all urls with given prefix, you don’t have to pass requested URI back, client can see it in javascript


Thanks for answering, and apologies for asking in the wrong channel. I agree this is not specifically a re-frame question. I know I can use URI’s with # in them, I just wanted to try w/out. I know its possible because @pupeno talks about it here And yes thinking about it there’s no need to send back the requested URI. I’ll keep plugging away, thanks again.


@simax99: I would think pushy should give you some docs/examples how to deal with HTML5 push state w/out #


@darwin I found the project that @pupeno describes in his screencast on Github so I have a good example now. Thanks again.