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

discussion: Executing Bloc Events Synchronously Across Different Blocs #4353

Open
justin-prabhakaran opened this issue Feb 9, 2025 · 0 comments
Labels
documentation Documentation requested

Comments

@justin-prabhakaran
Copy link

I need to execute multiple events from different Blocs synchronously, ensuring that each event completes before the next one starts. Here's the current code:

  context.read<PaymentBloc>().add(GetSubscriptionDetails());
  context.read<HeartCounterBloc>().add(GetHeartValueEvent());
  context.read<StreakBloc>().add(GetStreakInfoEvent());
  context.read<ChatBloc>().add(UpdateUserStatusEvent(
          userId: context.read<UserProvider>().user.id, status: true));

The above code dispatches all events at once, but I want them to execute one after another, waiting for each event to complete before starting the next one.

  • Is there a better way to execute events from different Blocs synchronously?

  • Can Bloc Concurrency help here, or is there another recommended approach?

  • Are there any best practices for handling such scenarios?

@justin-prabhakaran justin-prabhakaran added the documentation Documentation requested label Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation requested
Projects
None yet
Development

No branches or pull requests

1 participant