Fork me on GitHub
#re-frame
<
2019-08-24
>
mafcocinco01:08:17

Newb Question: Could anyone point me to suggested reading on different ways of organizing a re-frame project once it reaches the point of not being able to have all subs in subs.clj, all events in events.clj, etc. I thought I remember reading something about it in the official re-frame docs but I can't seem to find the page. Thanks!

mafcocinco04:08:29

Thanks @superstructor! That is the one I was looking for.

👍 4
alpox14:08:10

I'm very new to re-frame and I was wondering if there is a streight-forward way to setup an event which is composed of multiple asynchronous events with intermediate values which depend on each other? I tried out https://clojars.org/day8.re-frame/async-flow-fx but wiith this I'd have to compare the whole event vectors to ensure that I react only to the exact event which I issued (And not another same event with different arguments)

alpox15:08:30

Some code for illustration:

(rf/reg-event-fx
  :create-root
  (fn [_ _]
    {:async-flow {:first-dispatch [:do-get-board "root"]
                  :rules [{:when :seen? :events :fail-get-board
                           :dispatch [:create-board "root" nil]}]}})))
I want to check if a board already exists in the database - and only create it if it is not. With this code, it could happen that another event is issued about at the same time and the fail-get-board reacts to it instead of the [:do-get-board "root"] event

alpox15:08:17

I guess one solution to this particular problem would be to extend the pouchdb api with a create-if-not-exists function but I was hoping to be able to rely on a small set of base-API functions and handle compositions on higher layers

jahson18:08:49

You can dispatch create and inside check if db exist before calling create. Or, you can just try to create and handle possible "already exist" exception. IMO there is no need for async-flow-fx in your case.

jahson18:08:28

And there is no real need to react only to the exact event.