Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): count native listeners / correctly disable listener if count == 0 #569

Merged
merged 1 commit into from Jan 26, 2022

Conversation

Legion2
Copy link
Contributor

@Legion2 Legion2 commented Jan 26, 2022

Overview

Fixes #567

Test Plan

The changed behavior is not observable, unless you watch the events send over the RN bridge

Note:
It would be better to also remove the android network listeners if there are no listeners in RN. I also develop other RN modules and there we use kotlin, coroutines and flows which allows us to implement RN modules in a reactive way without the overhead of managing threads, subscriptions, events and callbacks.

Copy link
Contributor

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks obviously correct and matches my mental model of what was needed after I read the related upstream react-native code when you logged the issue yesterday. Thanks a bunch for posting this

Separately - with regard to your comment on Kotlin use and how it might make things match the react-native programming model better, that does sound nice. I'm not personally motivated to do it but if you wanted to post a java-->kotlin PR we could certainly merge it, kotlin is the future for android development and there are numerous popular modules using it so that would work for me. Only thing I can think of there is making sure the kotlin version is pulled from ext block where possible so consuming libraries may specify it and not end up with multiple / conflicting runtime libs - I believe thats possible?

@mikehardy mikehardy added the pending merge A PR that will be merged shortly, waiting for CI or final comment label Jan 26, 2022
@mikehardy mikehardy changed the title android added correct listeners counting fix(android): count native listeners / correctly disable listener if count == 0 Jan 26, 2022
@mikehardy mikehardy merged commit 5ae16f6 into react-native-netinfo:master Jan 26, 2022
@mikehardy mikehardy removed the pending merge A PR that will be merged shortly, waiting for CI or final comment label Jan 26, 2022
github-actions bot pushed a commit that referenced this pull request Jan 26, 2022
## [7.1.9](v7.1.8...v7.1.9) (2022-01-26)

### Bug Fixes

* **android:** count native listeners / correctly disable listener if count == 0 ([#569](#569)) ([5ae16f6](5ae16f6))
@matt-oakes
Copy link
Collaborator

🎉 This PR is included in version 7.1.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Legion2 Legion2 deleted the fix-remove-listeners branch January 26, 2022 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android removeListeners implementation incorrect
3 participants