felangel / bloc

A predictable state management library that helps implement the BLoC design pattern
https://bloclibrary.dev
MIT License
11.69k stars 3.38k forks source link

Bloc to Bloc Communication Suggestion #338

Closed Habib23me closed 5 years ago

Habib23me commented 5 years ago

Hey, I would like to thank you for this awesome library am doing my second flutter project with it which is kind of ecommerce app.

So I have to blocs WishListBloc and CartBloc that needs to communicate the scenario arrises when items are moved from the wishListBloc to the cartBloc. What I wanted to do is when wishListBloc is requested to move Items to the cartBloc it first dispatches an (AddToCart) event and then listen if that was successful and then delete it from the wishList items;

This is my wishListBloc

WishListBloc It uses a singleton pattern and uses a mixin to handle accessing list(adding, removing ...)

and this is CartBloc CartBloc Thanks in advance!

felangel commented 5 years ago

Hi @Habib23me 👋 Thanks for the feedback! We are currently working through several approaches to help with Bloc to Bloc Communication and we are taking mixins into consideration!

Your input is much appreciated! Thanks so much for sharing and you can expect this to be included in v0.15.0 of bloc 👍