Fork me on GitHub
#re-frame
<
2015-12-20
>
danielgrosse07:12:59

Is it possible to call a Javascript function with a subscription? E.g.

(let [x (subscribe [:example])] (.foo js/Bar x))
I don't get it to work. ­čśĽ

mikethompson08:12:21

Depending on the type of @x you may have to make it fit for js consumption (.foo js/Bar (clj->js @x))

danielgrosse08:12:06

In my case, the call doesn't happen. Actually I don't have the code in front me. But does it matter that much, if the x is derefed or not. I mean the code should execute anyway, but give me an exception about the type of x. Isn't it?

mikethompson08:12:42

Yep the code should execute. If it isn't then there's some other issue

mikethompson08:12:18

But that code fragment above seems wierd.

mikethompson08:12:37

Meant to be a form-2 component ?

mikethompson08:12:14

Are you indeed trying to say .... if x changes then call .foo. on js/Bar ?

danielgrosse09:12:16

I have a form-3 component, which creates a div with an id. This component is called in a subscription. On willupdate the JS library is initiated with the ID from the subscription. At the didmount event I call a helper function with the upper code.

danielgrosse09:12:44

This has to access the Library to change some data.