-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Bad state: Stream has already been listened to. #110
Comments
Hi @synstin Thanks for your interest in the package. Try to convert the Stream to a Broadcast Stream: This allows multiple listeners. You can do this by using the subscription = Alarm.ringStream.stream.asBroadcastStream().listen((event) => print('ring')); Let me know if it fixes you issue. |
The same thing happens when apply asBroadcastStream(). |
Hi @synstin Ok I will see if I can change the plugin's stream to fix your issue. In the meantime, can you keep the same stream all the time ? |
Hey @synstin Are you sure your |
@gdelataillade We really appreciate your attention to the issue and will be using one stream unclosed for now while it is fixed. |
Alright. Just to be sure you can log the In the meantime, you can make your stream static. This way, you can keep it in the HomeController scope and initialize only once. It's what I did in the example app. class HomeController extends GetxController {
static StreamSubscription<AlarmSettings>? subscription;
@override
void onInit() {
subscription ??= Alarm.ringStream.stream.listen((event) => print('ring'));
}
@override
void onClose() async {
subscription?.cancel();
print('HomeController: onClose');
}
} |
Hi @synstin Any updates on this issue ? |
Could this perhaps help you?
|
Similar issue: #153 |
I just released version |
Alarm plugin version
2.1.1
Describe the bug
I subscribe to ringStream when I go to the home page and close the subscription when I leave the page.
However, when I go to the homepage, then back, then go to the homepage, I get the error
Bad state: Stream has already been listened to.
I don't know why I get that error even though I closed the stream. can you help?Device info
every device
The text was updated successfully, but these errors were encountered: