[Android] No possible to handle JavaScript addListener event on native side
See original GitHub issueI’m looking this code: https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcher.java#L144
Correct me if I’m wrong but there is not clean solution how to handle JavaScript call to addListener("event")
method from NativeEventEmitter.js
on native - Java side.
If I have on native side Java listeners it’s need to add/remove them according to add/remove on JavaScript side.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to know that a JS event listener is registered on the ...
addEventListener requires an asynchronous call over the bridge from JS to native, so it's possible that MyModule starts emitting events before ...
Read more >Sending Events to JavaScript from Your Native ... - Callstack
Android. Sending events from your Java module to JavaScript is pretty simple. The easiest way to do this is to use RCTDeviceEventEmitter ...
Read more >Sending Events to JavaScript from Your Native ... - Medium
Communication between native modules and JavaScript thread happens through an event bus or, to be more specific, the bridge.
Read more >React Native Events in Gory Details: What Happens on the ...
A listenerStore object containing arrays of listeners, functions that will be called when the matching event type is dispatched. · An addListener ......
Read more >Touch events - Web APIs - MDN Web Docs - Mozilla
When the user lifts a finger off the surface, a touchend event is sent. We handle this by calling the handleEnd() function below....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes I can call native method like @ReactMethod eventListeningStartedOnJS() but I don’t think this is cleanest solution. For iOS we can extend RCTEventEmitter and handle this:
Can we have the same for Android?
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we’re automatically closing issues after a period of inactivity. Please do not take it personally!
If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.