Fork me on GitHub
#re-frame
<
2018-02-27
>
caleb.macdonaldblack00:02:34

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

danielcompton00:02:06

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?

caleb.macdonaldblack00:02:42

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

caleb.macdonaldblack00:02:39

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

caleb.macdonaldblack01:02:27

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

nakiya03:02:45

Using lein re-frame template. lein new re-frame npuzzle +10x +garden +test +cider Then I deply to heroku as per instructions here: https://github.com/Day8/re-frame-template#production-build 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.

mikethompson03:02:39

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

mikethompson03:02:59

an issue in re-frame-template repo

gadfly36106:02:09

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

dimovich09:02:56

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

dimovich10:02:06

is there a more idiomatic way?

dimovich10:02:07

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

dimovich10:02:37

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

curlyfry10:02:15

@dimovich Event names should capture user intent. You can find some idiomatic events in the todomvc example in the re-frame repo: https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/events.cljs

dimovich11:02:39

@curlyfry thanks for your suggestion!

gadfly36116:02:16

@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

danielcompton19:02:41

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

danielcompton19:02:55

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

dimovich21:02:09

@gadfly361 works fine this way. thanks!