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

docs: sorry in advance #3935

Closed
axroromonov44 opened this issue Aug 18, 2023 · 3 comments
Closed

docs: sorry in advance #3935

axroromonov44 opened this issue Aug 18, 2023 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@axroromonov44
Copy link

I want to kill the Flutter Bloc when it leaves the page. My request takes a long time (it goes to several services), the user can back it up without a response, and even before it reaches some services, is there another way for me to dispose? thanks in advance for the reply

@axroromonov44 axroromonov44 added the documentation Documentation requested label Aug 18, 2023
@elianortega
Copy link
Contributor

@axroromonov regarding the Bloc disposal, the BlocProvider will automatically handle closing, so whenever the BlocProvider widget gets disposed it will call bloc.close too. So if you are intending to close the bloc whenever the page is popped, you can add the BlocProvider inside that same page.

Regarding the canceling of the call to the several services, you should think of some logic to cancel those request independently and then handling the canceling on the close function of the bloc.

There is a feature request from 2021 talking about canceling all pending asynchronous operation on bloc close, you can read more about it in #3069.

@axroromonov44
Copy link
Author

regarding the Bloc disposal, the BlocProvider will automatically handle closing, so whenever the BlocProvider widget gets disposed it will call bloc.close too. So if you are intending to close the bloc whenever the page is popped, you can add the BlocProvider inside that same page.

Regarding the canceling of the call to the several services, you should think of some logic to cancel those request independently and then handling the canceling on the close function of the bloc.

There is a feature request from 2021 talking about canceling all pending asynchronous operation on bloc close, you can read more about it in #3069.

I'm just looking for a way to exit the page other than dispose via block , or block.close(); is it enough for me?

@felangel
Copy link
Owner

@axroromonov when you pop a page (unmount a widget) that contains a BlocProvider it'll automatically close the bloc.

Closing for now but feel free to comment with additional questions and I'm happy to continue the conversation 👍

@felangel felangel self-assigned this Sep 13, 2023
@felangel felangel added question Further information is requested and removed documentation Documentation requested labels Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants