Fork me on GitHub
#re-frame
<
2017-05-09
>
danielneal09:05:36

Hey, I'm new to re-frame! I'm figuring out interceptors and effects...If I use the path interceptor does that mean I can't update the db in a reg-event-fx (for instance to show loading? when making an http request)

danielneal09:05:48

(reg-event-fx
 :recipe-search/search
 [validate-spec (path :ui :recipe-search)]
 (fn [{:keys [query] :as recipe-search} _]
  *{:db (assoc-in db [:ui :recipe-search :loading?] true) *
    :http-xhrio {...}}))

danielneal09:05:20

i.e. what should I put instead of the db line in the above

curlyfry10:05:26

danielneal: path lets you skip the whole part with assoc-in and path, so you can do something like {:db (assoc db :loading? true)}

curlyfry10:05:59

And the value will be added to the right place in your main app-db by the interceptor

danielneal10:05:27

ah great thank you!

danielneal10:05:47

it was this line

2. `:effects` may not contain `:db` effect. Which means no change to
       `:db` should be made.
that threw me

danielneal10:05:23

but it sounds like I just treat the path as :db and everything will work out

curlyfry11:05:41

Ah, that is a bit amiguous! It's "may not" as in "it's possible that there isn't" rather than "it's not allowed" :)

joshkh12:05:41

it's pretty obviously a CLJS dev tools problem but i've never seen it before. has anyone else experienced this?

joshkh12:05:14

expanding any other key/value pair works fine. it's only the :db keys!

gklijs11:05:39

joshkh: I have the same problem, did not have time to dive into it.

souenzzo13:05:27

How are you handle with input? I move my inputs from "local" ratom to "db" and it's buggy when I type fast (or in slow machines). I move from (defn x [] (let [a (atom "")] (fn [] [:input {:value @a :on-change #(reset! a %.target.value)}]))) To (defn x [] [:input {:value @(subscribe [:my-from]) :on-change #(dispatch [:update-form %.target.value])}])))

mikethompson13:05:29

In your :on-change Try using dispatch-sync instead of dispatch

mikethompson13:05:25

A slightly ugly hack but if very fast keypresses are causing a problem then this is an out

mikethompson13:05:01

Then again, this might be because of debug middleware slowing down event processing, and that might disappear in prod builds. Just an idea

mikethompson13:05:24

OR perhaps easiest of all, just use on-blur

souenzzo14:05:26

I will try dispatch-sync. My :advanced builds also buggy on(just) [email protected]

souenzzo14:05:11

@mikethompson how did you handle form events? I made a :form event and sub. Then I use on forms (dispatch [:form :unique-name]) and (subscribe [:form :unique-name])

souenzzo16:05:26

Awesome @joshkh!!! Not sure if I will use it for input, but sure for sync with remote!!!

dfcarpenter21:05:41

Is anyone using graphql with reagent/reframe projects?

kenny21:05:51

I messed around with it. Nothing too special about the integration on the frontend.

isak22:05:25

is there a natural way to represent graphql queries in clojure syntax? i.e., not a string