Fork me on GitHub

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!


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

👍 4

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 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)


Some code for illustration:

  (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


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


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.


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