Fork me on GitHub
#re-frame
<
2017-01-19
>
nrako17:01:22

Any ideas why I might be getting an Invariant Violation when rendering?

nrako17:01:34

react.inc.js:19817 Uncaught Invariant Violation: Expected onClick listener to be a function, instead got type object

nrako18:01:09

The results in the console log are showing that the :on-click handler is indeed a function, so perhaps it has to do with the timing of React rendering? Appreciate any insights...

neurogoo20:01:17

Hi. I have html audio tag that has src which is updated with subscription. But how I can launch play event after and only after subscription has been updated? I can't just dispatch update-src and play events at the same time as I have understood correctly ordering of events are not anyway guaranteed.

nrako20:01:48

@neurogoo you are looking for auto-play when the subscription (audio source) changes?

neurogoo20:01:45

basically yes

nrako20:01:23

You may need an on-change listener attached the src which dispatches a second event to fire the audio player

neurogoo20:01:33

I may be completely wrong, but I don't think that audio tag supports on-change

neurogoo20:01:11

but it seems that it does have loadstart event that should be enough for me for now

nrako20:01:38

@neurogoo still thinking about this. A subscription is effectively an on-change listener, Can you just add a new subscription?

neurogoo20:01:56

Where I would attach this new subscription?

nrako20:01:01

I have never tried myself, but in hiccup I would guess (fn [src] [:audio [:source {:src src}]])

nrako20:01:27

then you deref @src, and it should repaint when the subscription changes?

neurogoo20:01:39

ah yes, that how I do it now with src, but where you would attach subsription listener that would launch play event?

nrako20:01:42

you could drop it in the html somewhere, and deref when it is called - i.e [:div (said-audio-fn @src)]

nrako20:01:03

again, just guessing 🙂

neurogoo20:01:43

Feels a little unelegent to have extra html elements just for doing effects

nrako20:01:39

Have you checked out https://github.com/Day8/re-frame/blob/master/docs/EffectfulHandlers.md#effectful-handlers? Might have some tips for performing side-effects

nrako20:01:53

if you don't want it on the dom

neurogoo20:01:47

I did look it, but if I remember correctly the order of the returning map is not anyway forced

neurogoo20:01:17

for the side-effect

superstructor21:01:27

correct, order is not enforced for effects @neurogoo