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
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])}
@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.
Thanks for the feedback guys. I appreciate it 🙂
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
For production, a re-frame app is going to end up being a .js
file, plus some css files, etc.
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?
On the other hand, perhaps you are talking about dockerising the server side?
@ramonp.rios ^^
On my case, i already have my backend dockerized
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
Thanks for the tips @mikethompson
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
)
@ramonp.rios ^^
You then need to get them into a Docker image which will serve them
What’s the latest re-frame modal library these days?
I see re-frame-modal
but it’s a few years old.
Unless that means it’s tried and true.
@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.