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: close ListenManual subscriptions after State.dispose() #1980

Conversation

nawafalomari
Copy link
Contributor

This PR fixes the bug mentioned in this issue #1889 by closing the ListenManual after calling dispose().

@rrousselGit
Copy link
Owner

Could you fix the CI and add tests?

@nawafalomari
Copy link
Contributor Author

Could you fix the CI and add tests?

Sure, I'm on it 👍🏻

@codecov
Copy link

codecov bot commented Dec 5, 2022

Codecov Report

Merging #1980 (1b3780c) into master (97e28b6) will not change coverage.
The diff coverage is n/a.

❗ Current head 1b3780c differs from pull request most recent head 7fd6da8. Consider uploading reports for the commit 7fd6da8 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1980   +/-   ##
=======================================
  Coverage   96.22%   96.22%           
=======================================
  Files          48       48           
  Lines        2013     2013           
=======================================
  Hits         1937     1937           
  Misses         76       76           

@nawafalomari
Copy link
Contributor Author

@rrousselGit I fixed the formatter CI issue, but I'm not quit sure how to test that the subscription is been closed after dispose is called. There is a test now to check that it is closed on dispose. Do you have any ideas?

@rrousselGit
Copy link
Owner

The goal of that issue is to be able to call subscription.read() within dispose overrides.
You could do that in a test.

class A extends ConsumerState<...> {
  late final sub = ref.listen(provider, (prev, next) {});
  
  void dispose() {
    sub.read().doSomething();
    super.dispose();
  } 
}

@rrousselGit rrousselGit merged commit f6e6e4d into rrousselGit:master Dec 21, 2022
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 this pull request may close these issues.

None yet

2 participants