React-native-reanimated: Is it possible to bind to custom events?

Created on 7 Aug 2020  路  3Comments  路  Source: software-mansion/react-native-reanimated

I'm working on an Android app that receives events from a custom hardware integration. I have some java code that sends these events over the react-native bridge so that react-native-reanimated can play animations from these events. However, receiving these events in the JS thread is slowing down the UI. I鈥檇 like to use react-native-reanimated to bind to these events without having to impede the JS thread. Basically I'm looking for a way to bind to these custom events just like I would for gestures or scrolling events.

I did some searching for examples of react-native-reanimated integrating with custom events but I couldn鈥檛 find anything. Is this even possible? Are there any good examples of this or source code that would be a good reference?

鉂換uestion

Most helpful comment

@jakub-gonet @cmnstmntmn thanks! Yeah I'll reference react-native-gesture-handler.

I'll maybe post some code snippets here if I get everything working right so anyone else with a similar question has a clear example.

All 3 comments

@robertgonzales yes, have a read

Reanimated doesn't keep any list of RN events so if you're dispatching events via RN interfaces and methods it should be supported.

I didn't personally come across an example, but you can check react-native-gesture-handler implementation which registers two new events types.

If you have further questions feel free to ask.

@jakub-gonet @cmnstmntmn thanks! Yeah I'll reference react-native-gesture-handler.

I'll maybe post some code snippets here if I get everything working right so anyone else with a similar question has a clear example.

Was this page helpful?
0 / 5 - 0 ratings