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

[Question] Do we need to cancel a StreamSubscription ? #20

Closed
Mihai-B opened this issue Aug 25, 2023 · 2 comments
Closed

[Question] Do we need to cancel a StreamSubscription ? #20

Mihai-B opened this issue Aug 25, 2023 · 2 comments

Comments

@Mihai-B
Copy link

Mihai-B commented Aug 25, 2023

I am still in the testing fase of this plugin but I am starting to like it. Thank you for your work.
I do have a question related to the functionality of this plugin:

I want to now if I have to manualy close a StreamSubscription or not.
So if you have a code that looks like this:

CombineInfo isolateInfo = await Combine().spawn((context) {
  print("Argument from main isolate: ${context.argument}");

  context.messenger.messages.listen((message) {
    print("Message from main isolate: $message");
    context.messenger.send("Hello from isolate!");
  });
}, argument: 42);

 StreamSubscription<Object?> workerSubscription = isolateInfo.messenger.messages.listen((message) {
     // your code to handle messages from isolate
    });

Is it required to close the StreamSubscription or when calling the method isolateInfo.isolate.kill(); will also handle the closing of the StreamSubscriptions ?

@Maksimka101
Copy link
Owner

Hello. Glad to hear it

All combine related stuff, streams included, will be closed when it's killed. So your subscription will be closed as well

@Mihai-B
Copy link
Author

Mihai-B commented Aug 25, 2023

Nice, thank you for the info.

@Mihai-B Mihai-B closed this as completed Aug 25, 2023
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

No branches or pull requests

2 participants