breautek edited a comment on issue #110: URL: https://github.com/apache/cordova-plugin-network-information/issues/110#issuecomment-634939949
I've reproduced the described behaviour on an Android API 29 simulator using the latest cordova tooling and plugin. Just posting some information... Couple of different theories. ### Theory 1 Broadcast event is firing because we unregister and register to the native listener onPause/onResume. I assume the act of registering the event causes the event to fire at least once, producing an event to the javascript. It didn't always unattach/re-attach the listener on pause/resume. This was changed by https://github.com/apache/cordova-plugin-network-information/pull/74 for https://github.com/apache/cordova-plugin-network-information/issues/64 ### Theory 2 The native broadcast simply fires when the activity is resumed. I'm not really sure on the behaviour of the Intent broadcaster, but if theory 2 is actually what is happening, then I don't think this is a bug. But if I were to make a bet, I think Theory 1 is why we are seeing these events on pause/resume. If we consider this a bug, then I think we should keep track of connection types, and only propagate the event to the javascript **if** the connection type actually changes. I'd support a PR that makes this change. I'd also like to see if this behaviour is observable on iOS, but I don't have mac equipment to use to test this. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
