Fork me on GitHub
#cljsrn
<
2021-05-13
>
ullrich19:05:15

Did anybody look into possibilities to use re-animated worklets with cljs? They require a Babel transpiration step and I’m wondering what it would take to make them work with shadow or krell. https://docs.swmansion.com/react-native-reanimated//react-native-reanimated/docs/worklets/

thheller19:05:23

you can write them in JS and use them from CLJS, writing them in CLJS is not possible

ullrich19:05:22

So I would write them in JS, transpile and then require the result in shadow? I wonder how callbacks would work though. I think I need to take a look at the transpilation result to get a better idea of them.

dnolen19:05:22

you shouldn't have interop problems - certainly not callbacks

dnolen19:05:18

been working on a project for over a year where all UI components are written in JS, not just 3rd party stuff from libs - no issues

cljs 3
ullrich20:05:34

I’m actually looking into the possibilities that https://github.com/mrousavy/react-native-multithreading offers for loading of heavy work off of the JS thread. They use the same worklet API. It doesn’t assume callbacks though, but returns the result as a promise. I’ll play with it a bit. I’m just starting to look into this and haven’t fully sunk my mind into it yet. wondering if it would be possible to call an exported CLJS fn from the JS worklet. Would love to keep my logic in Clojure.

thheller20:05:04

I think that is of fairly limited use since those "worklets" or threads still cannot share memory

thheller20:05:47

so as soon as you need access to data in those you'll pay serialization costs, which quite often will make things actually slower and not worth it

ullrich20:05:32

Yes, very valid concern. I’m a bit desperate to try it out though ;) Will report back, even if just for academic purpose :)

raspasov20:05:27

@ullrich.schaefer I also wanted to use worklets from pure CLJS but it’s not really possible; one thing that works is that you can pass CLJS fn to the JS side and call the fn there; works easily for JS primitives etc; if you want your CLJS function to accept CLJS data, that would be more involved, I think, and not sure if it’s easily possible; but just primitives or JS objects should be good enough for most cases;

👍 3