This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-20
Channels
- # aleph (4)
- # beginners (47)
- # boot (22)
- # cider (7)
- # clara (1)
- # cljs-dev (8)
- # cljsrn (21)
- # clojure (180)
- # clojure-argentina (13)
- # clojure-gamedev (1)
- # clojure-italy (5)
- # clojure-poland (4)
- # clojure-russia (17)
- # clojure-spec (19)
- # clojure-uk (33)
- # clojurescript (107)
- # cursive (61)
- # data-science (1)
- # datomic (7)
- # emacs (69)
- # euroclojure (1)
- # graphql (1)
- # hoplon (11)
- # immutant (43)
- # jobs (1)
- # leiningen (3)
- # off-topic (5)
- # om (10)
- # onyx (2)
- # parinfer (52)
- # pedestal (11)
- # re-frame (31)
- # reagent (23)
- # ring-swagger (3)
- # schema (2)
- # specter (7)
- # unrepl (9)
@pandeiro https://github.com/pesterhazy/re-frame/blob/b84afb9db35288c516b06eefc40fae33d9c820db/docs/Debugging-Event-Handlers.md#too-much-repetition---part-1
this is probably noob question, how do I simplify following construct:
[:div.my-list
(map (fn [i] [ui-item i]) ["foo" "bar" "zap"])]
Why simply doing:
[:div.my-list
(map ui-item ["foo" "bar" "zap"])]
Doesn't work?@pandeiro sorry this is the right link: https://github.com/Day8/re-frame/blob/master/docs/Debugging-Event-Handlers.md#too-much-repetition---part-2
Ah yep @mikethompson - I was gravitating toward doing that
@ag when you say it didn't work, what aspect didn't work for you?
Okay, I'm going to have to go ... so here are some quick notes: Try
[:div.my-list (for [i ["foo" "bar" "zap"]] [ui-item i])]
or
(into [:div.my-list] (for [i ["foo" "bar" "zap"]] [ui-item i]))
You'll get some warnings on the first one which can be removed by adding keys:
[:div.my-list (for [i ["foo" "bar" "zap"]] ^{:key i} [ui-item i])]
Finally, be sure you are across this aspect of Reagent: https://github.com/Day8/re-frame/wiki/Using-%5Bsquare-brackets%5D-instead-of-%28parentheses%29
You probably do, but just checking
idk if you talk much about re-com in here, but, I'm looking at using the typeahead component for something, and it seems no matter what I return from my data-source it throws this error:
@mikethompson I guess we'll need to wait for v0.9.5 to use the new dispatch-n
>@talgiat :dispatch-n
seems to not mind having nil
in the collection you provide it, I'm not sure this is officially supported but I just use when inline in the vector I provide to dispatch-n
From @mattly earlier ^^^ So it already works. All I've done is to make it official.
You don't have to wait
Ahh, damn.
Wait on
Ah, yes: https://github.com/Day8/re-frame/blob/master/src/re_frame/router.cljc#L239
So, you'll just have to monkey patch for the moment. until the new version comes out
Register your own dispatch-n
handler which will overwrite the official one
Put this is your core.cljs:
(register
:dispatch-n
(fn [value]
(if-not (sequential? value)
(console :error "re-frame: ignoring bad :dispatch-n value. Expected a collection, got got:" value))
(doseq [event (filter nil? value)] (router/dispatch event))))
Go on
I love a good hack
yeah, the only minor annoyance is you get a console warning when the app loads about overriding the dispatch-n effect. Oh well, I can remove it before I register the monkey patch,
has anyone felt the need to make a request queue for http requests in re-frame. I'm thinking I need such a thing for the app I am working on, so I can optimistically update the db, but queue up requests in the case of patchy internet, and was wondering if there was any prior art.
I haven't seen one, but it's a neat idea