Fork me on GitHub

We are building a wep app with re-frame and trying to refactor some of our events. Each time something is changed, The app-db is updated, the remote db is updated (http request) and pusher is updated (websocket). Managing all three is getting a little out of hand. We are considering using interceptors with some business logic events. A change is made -> Business logic event dispatched -> decide whether or not we are happy with the change -> dispatch 2nd business logic event with 3 attached interceptors. (Update app-db, remote-db & pusher). Just wanted to get others thoughts on this approach, and see what other people have done in similar situations


I could also imagine doing something similar as an fx, where you put all of the logic in the fx handler. I think either way would work ok though?


We have our http requests and pusher events set up as fx, although a fair few parameters in the fx are repeated. So we end up with 2 events which return fx (to keep it DRY) & our primary event will dispatch-n the three events


We like the idea of being able to “bolt on/attach” functionality to our event easily with interceptors, without needing to worry too much what effects are happening within the handler itself. Our handlers would be primarily business logic


Alright well if that doesn’t sound crazy I’ll give it ago and see if makes things easier. Cheers


Using lein re-frame template. lein new re-frame npuzzle +10x +garden +test +cider Then I deply to heroku as per instructions here: I get these errors in app log in heroku:

2018-02-27T03:28:46.620804+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2018-02-27T03:28:46.626435+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -Dfile.encoding=UTF-8 
2018-02-27T03:28:52.373794+00:00 app[web.1]: No :main namespace specified in project.clj.
2018-02-27T03:28:52.374621+00:00 app[web.1]: Error encountered performing task 'trampoline' with profile(s): 'production'
2018-02-27T03:28:52.374755+00:00 app[web.1]: No :main namespace specified in project.clj.
What is the main namespace asked for here? I’m quite new to clojure, google didn’t help here.


@duminda can you create an issue please, we'll deal with it that way


an issue in re-frame-template repo


@duminda You need to add the +handler profile to be able to deploy to heroku CC @mikethompson


I find myself writing events like ::assoc, and ::update, etc...


is there a more idiomatic way?


@gadfly361 a bit offtopic, but how can I defer rendering Rid3 charts only after component has finished mounting


I want to display my page as fast as possible, and only later draw the charts


@dimovich Event names should capture user intent. You can find some idiomatic events in the todomvc example in the re-frame repo:


@curlyfry thanks for your suggestion!


@dimovich hmm, you could create a placeholder div that is the same dimensions as your rid3 component that is displayed on page load and then replace it with your rid3 component as a result of some event that is dispatched on a did-mount life cycle event for the page component


@dimovich I agree with @curlyfry, I think there's some docs somewhere that covers this, but I couldn't find them quickly


But it's a common question, and a reasonable one to ask


@gadfly361 works fine this way. thanks!