Fork me on GitHub
#re-frame
<
2019-06-14
>
upgradingdave12:06:00

Hi all, quick question … I’d like to use the dispatch-later fx handler so I required the fx ns in my namespace: (:require [re-frame.fx])

upgradingdave12:06:13

is there anything else I need to do in order to use :dispatch-later?

upgradingdave12:06:19

here’s how I’m trying to use it:

upgradingdave12:06:56

`(rf/reg-event-fx ::start (fn [cofx [_ msg]] (let [{:keys [animation-key follower]} msg] {:db {animation-key {:follower follower :running? true}} :dispatch-later [:ms 1000 :dispatch [::stop]]} )))`

upgradingdave12:06:42

doh! thanks, I knew it must be something simple, thanks!

mikethompson12:06:03

My suggested code doesn;t match the docs

mikethompson12:06:27

:dispatch-later [{:ms 1000 :dispatch[::stop]]}

mikethompson12:06:03

There, that's better

upgradingdave12:06:25

yes, perfect, that worked! excellent

credulous16:06:08

Is anyone aware of an example of using re-frame with a type-3 component (e.g. using component lifecycle events)? My google-fu is failing me

shaun-mahood16:06:53

@credulous https://github.com/reagent-project/reagent/blob/master/doc/CreatingReagentComponents.md has the different types of components - it's one of the docs I have found difficult to find with google

credulous16:06:39

Thanks Shaun. I’ve been following that doc, but it doesn’t use re-frame. I’ve tried putting a reframe subscription in my component-did-update method, but it doesn’t get called when events are dispatched.

credulous16:06:20

Thanks, I’ll study that … I can already see that it’s unlikely I’d have gotten there anytime soon, so thanks!

shaun-mahood16:06:02

The code in there might be a little more complicated than necessary - the way that library is built may make it hard to separate the part you want from the other things it's doing there

shaun-mahood16:06:52

It looks to me like you should be able to subscribe directly inside the component-did-update, though, as long is it's all inside the function

credulous17:06:18

Thanks so much, that’s awesome. It even references Google Maps — I’m trying to integrate Mapbox, different but same

valtteri18:06:03

I’ve done it for OpenLayers :)