Fork me on GitHub
#re-frame
<
2017-07-20
>
ag01:07:46

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?

pandeiro01:07:31

Ah yep @mikethompson - I was gravitating toward doing that

mikethompson01:07:07

@ag when you say it didn't work, what aspect didn't work for you?

mikethompson01:07:57

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

mikethompson01:07:01

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

mikethompson01:07:41

You probably do, but just checking

mattly01:07:43

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:

mattly01:07:11

where "430" is some positive integer or another

mattly01:07:05

I've tried with both synchronous and async datasources, with a static result

talgiat05:07:30

@mikethompson I guess we'll need to wait for v0.9.5 to use the new dispatch-n

mikethompson05:07:00

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

mikethompson05:07:43

From @mattly earlier ^^^ So it already works. All I've done is to make it official.

mikethompson05:07:08

You don't have to wait

talgiat05:07:57

I've tried with v0.9.4 and it threw exception

mikethompson05:07:57

So, you'll just have to monkey patch for the moment. until the new version comes out

mikethompson05:07:27

Register your own dispatch-n handler which will overwrite the official one

mikethompson05:07:09

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

talgiat05:07:21

yeah, that's exactly what I did

mikethompson05:07:30

I love a good hack

talgiat05:07:08

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,

danielneal08:07:51

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.

danielcompton08:07:01

I haven't seen one, but it's a neat idea