Fork me on GitHub
#re-frame
<
2018-03-05
>
caleb.macdonaldblack06:03:55

@gadfly361 https://github.com/CalebMacdonaldBlack/re-frame-interceptors-demo/blob/functions/src/cljs/demo/events.cljs Heres what I ended up with. To summarise my problem, I’m trying to define the pathways/decision tree for my business logic in my event handler. I do not want to bounce around functions (or events) trying to map in my head what the logic is doing.

caleb.macdonaldblack06:03:37

This allows me to define the condition and the path for a branch. I can also chain events together (For example http-xhrio).

caleb.macdonaldblack06:03:25

I will likely add more ways to branch (cond, case, when ect) as I need them if this works out.

gadfly36106:03:40

@caleb.macdonaldblack thanks! Looking over the code, definitely intrigued by this approach. Excited for later when I can play around a bit in the repl and get a feel for it. Keep up the creativity!

caleb.macdonaldblack08:03:19

Let me know any feedback you have 🙂

fabrao12:03:42

Hello all, sorry about my silly question, but I saw many examples, but nothing with re-frame/reagent to clear explain how do I use the select with option with re-frame/reagent? How to set :value and :on-change, is that the same as input?

erwinrooijakkers12:03:29

I have an effect handler (`reg-fx`). I want to store the item that is created in the effect in the db. What is the best way to do this?

p-himik17:03:45

@fabrao Should be the same, yeah. @erwinrooijakkers Effects can cause side-effects, so you can just use (reset! db some-new-db-value). For an example you can look the the :db effect handler implementation.

erwinrooijakkers17:03:50

Okay I injected the effects via cofx into a reg-event-db, but it is a bit much indirection

erwinrooijakkers17:03:10

If reg-event-fx can just create some stuff and add it to the database it is clearer

erwinrooijakkers17:03:01

E.g.,

(re-frame/reg-event-fx
 :initialize
 [(re-frame/inject-cofx :one-thing-that-uses-my-value)
  (re-frame/inject-cofx :another-thing-that-uses-one-thing-obtained-from-cofx)]
 (fn [{:keys [db one-thing another-thing] :as cofx} [_ my-value]]
   {:db (assoc db
               ::one-thing one-thing
               ::another-thing another-thing)}))

erwinrooijakkers17:03:21

And I meant creating the stuff in a let block and then associng it to the db is clearer