This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-09
Channels
- # aws (4)
- # bangalore-clj (1)
- # beginners (94)
- # boot (19)
- # cider (42)
- # cljs-dev (21)
- # cljsrn (4)
- # clojure (142)
- # clojure-austin (10)
- # clojure-greece (25)
- # clojure-italy (14)
- # clojure-russia (14)
- # clojure-serbia (13)
- # clojure-sg (6)
- # clojure-spec (74)
- # clojure-uk (69)
- # clojurescript (236)
- # consulting (1)
- # cursive (26)
- # data-science (6)
- # datascript (2)
- # datomic (31)
- # editors (5)
- # emacs (24)
- # funcool (5)
- # hoplon (8)
- # jobs-rus (1)
- # luminus (12)
- # lumo (17)
- # off-topic (90)
- # om (45)
- # onyx (5)
- # pedestal (2)
- # powderkeg (12)
- # protorepl (2)
- # re-frame (30)
- # remote-jobs (2)
- # ring-swagger (17)
- # rum (46)
- # slack-help (1)
- # test-check (2)
- # yada (62)
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)
(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 {...}}))
i.e. what should I put instead of the db line in the above
danielneal: Check out the doc: https://github.com/Day8/re-frame/blob/master/src/re_frame/std_interceptors.cljc#L142
danielneal: path
lets you skip the whole part with assoc-in and path, so you can do something like {:db (assoc db :loading? true)}
And the value will be added to the right place in your main app-db by the interceptor
ah great thank you!
it was this line
2. `:effects` may not contain `:db` effect. Which means no change to
`:db` should be made.
that threw mebut it sounds like I just treat the path as :db and everything will work out
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" :)
hey @danieleneal , longtime !
it's pretty obviously a CLJS dev tools problem but i've never seen it before. has anyone else experienced this?
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])}])))
In your :on-change
Try using dispatch-sync
instead of dispatch
A slightly ugly hack but if very fast keypresses are causing a problem then this is an out
Then again, this might be because of debug
middleware slowing down event processing, and that might disappear in prod builds. Just an idea
OR perhaps easiest of all, just use on-blur
@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])
@souenzzo maybe you could debounce the function? https://www.martinklepsch.org/posts/simple-debouncing-in-clojurescript.html
Awesome @joshkh!!! Not sure if I will use it for input
, but sure for sync with remote!!!
Is anyone using graphql with reagent/reframe projects?
is there a natural way to represent graphql queries in clojure syntax? i.e., not a string
we've been using this query syntax instead: https://github.com/omcljs/om/blob/master/src/main/om/next/impl/parser.cljc#L15-L23
Maybe look into this: http://lacinia.readthedocs.io/en/latest/