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

FlutterBlue.state cancels all subscriptions if only one listener cancels #608

Open
MacMalainey opened this issue Jun 16, 2020 · 0 comments · May be fixed by #609
Open

FlutterBlue.state cancels all subscriptions if only one listener cancels #608

MacMalainey opened this issue Jun 16, 2020 · 0 comments · May be fixed by #609

Comments

@MacMalainey
Copy link

I have only verified this behaviour on Android. But what happens is if there are two listeners to FlutterBlue.state and one cancels its subscription, it appears to cancel every stream. I did some digging and it appears that flutter blue generates a new broadcast stream that listens to the native level per listener that subscribes, which when a single stream closes it then sends the cancel command to the native level.

final fb = FlutterBlue.instance;
var sub1 = fb.state.listen (doStuff);
var sub2 = fb.state.listen(doOtherStuff);

sub1.cancel();
// sub2 will no longer receive events now

Code of interest:
Android Native StateStream Handler
Dart Implementation of FlutterBlue.state

MacMalainey added a commit to MacMalainey/flutter_blue that referenced this issue Jun 17, 2020
Fix bug where if there were multiple subscribers to FlutterBlue.state
and one cancelled it would accidentally cancel all subscribers
Fix for: pauldemarco#608
@MacMalainey MacMalainey linked a pull request Jun 17, 2020 that will close this issue
MrCsabaToth added a commit to CsabaConsulting/flutter_blue that referenced this issue Jun 13, 2021
MrCsabaToth added a commit to CsabaConsulting/flutter_blue that referenced this issue Jun 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant