re-frame

https://github.com/Day8/re-frame/blob/master/docs/README.md https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md
Shako Farhad 2020-08-20T06:59:39.005900Z

Hey guys. I have a question. If I want to dispatch an event as soon as there is a change to a specific value in my app-db, how should I do that? Can I dispatch events in reg-sub? Or do I put the dispatch in with the view like this: (do (dispatch event) [:div "hello"]) My backend is sending patch diffs of state through sse and I just merge them into my app-db. But certain keys in my db need to trigger an event. Any suggestions? :x

Lu 2020-08-20T09:16:39.009200Z

Never dispatch in reg-sub or in the rendering function. What I would do is to check if the diffs contain the key that should trigger the event, and if so, you can dispatch from your event-fx like so:

{:db diffed-db
 :dispatch (when (:trigger diffed-db)
             [:event-to-dispatch])}

p-himik 2020-08-20T09:23:05.010Z

@shakof91 There's re-frame.core/on-changes interceptor that does what you want. Combined with somewhat recently introduced global interceptors, this should cover your need.

👆 2
Shako Farhad 2020-08-20T09:24:02.010400Z

Thanks for the feedback guys. I appreciate it 🙂

Ramon Rios 2020-08-20T10:36:15.011600Z

Folks, have you tried to dockerize a re-frame app? I'm kinda lost if a need to treat as a usual npm app or do i need something different

2020-08-20T10:37:45.012600Z

For production, a re-frame app is going to end up being a .js file, plus some css files, etc.

2020-08-20T10:41:05.015700Z

It is just a client side framework. So you will need a way to "serve" these files. Perhaps you use a two stage Docker file which first builds the production artifacts (js, css, html, etc) and then copies them into a nginx image?

2020-08-20T10:41:27.016200Z

On the other hand, perhaps you are talking about dockerising the server side?

2020-08-20T10:41:53.016900Z

@ramonp.rios ^^

Ramon Rios 2020-08-20T10:41:54.017100Z

On my case, i already have my backend dockerized

Ramon Rios 2020-08-20T10:42:41.018Z

In my head, pretty easy, just get the jar and execute it. But i never did something with .js files i and was looking at it now

Ramon Rios 2020-08-20T10:42:48.018300Z

Thanks for the tips @mikethompson

2020-08-20T10:45:16.020400Z

If you use the re-frame-template to create an application ... ... you can use the lein release command (see the README) which will build the production artifacts (in /resources)

2020-08-20T10:45:24.020600Z

@ramonp.rios ^^

2020-08-20T10:45:54.021300Z

You then need to get them into a Docker image which will serve them

jmckitrick 2020-08-20T21:21:04.021900Z

What’s the latest re-frame modal library these days?

jmckitrick 2020-08-20T21:23:13.022300Z

I see re-frame-modal but it’s a few years old.

jmckitrick 2020-08-20T21:23:20.022500Z

Unless that means it’s tried and true.

2020-08-20T23:59:33.024Z

@jmckitrick You don't need anything re-frame specific. You just need a Reagent component. Perhaps look at re-com or google for "Reagent Material UI" etc.