I want to use events to communicate between native ios/android and my react native app.
I see two ways to do this: DeviceEventEmitter and NativeAppEventEmitter, which seem to be fairly identical.
What's the difference between them? Why should I pick one over the other?
I've found I need to use both when developing cross-platform native extensions that need to send events from Java/Obj-C to JavaScript.
On iOS you send events to JS like this:
.. which you pick up in JS using
NativeAppEventEmitter
.In Java you send events to JS with:
.. which you pick up in JS using
DeviceEventEmitter
It's not ideal, as your JS code needs to then choose the right emitter for the events to be received.
E.g.