Maksimka101 / isolate-bloc

A Flutter package that helps implement the BLoC pattern when blocs run in their own Isolate.
MIT License
21 stars 9 forks source link

Migrate to Flutter 2 with null-safety and update the API #12

Closed Maksimka101 closed 3 years ago

Maksimka101 commented 3 years ago

Updates in API

Maksimka101 commented 3 years ago

10 #9

f-person commented 3 years ago

I think it's a good idea to replace the current onEventReceived with the traditional mapEventToState. And, in general, I think we should make the interface correspond to flutter_bloc as much as possible. It would make easier for people to understand and start using isolate_bloc. Maybe we should even consider making it possible to run a cubit in an isolate. However, I'm not sure if it's worth the effort (as I don't currently know how much effort this requires to be done) and it's not something urgent so it can be done in the future.

Maksimka101 commented 3 years ago

I agree with you but should we replace onEventReceived with mapEventToState or just add another way to handle events?

The main idea of onEventReceived method is its simlicity. You must not deal with complex async generators or even more complex situations when you need to update state without ui intent. You just receive event and emit state at any place

Maybe we should just add mapEventToState to the existing IsolateBloc or separated entities for each approach? Bloc with onEventReceived may be some kind of IsolateCubit while bloc with mapEventToState may be IsolateBloc

Maybe we should even consider making it possible to run a cubit in an isolate

I think it is imossible without codegeneration

f-person commented 3 years ago

Bloc with onEventReceived may be some kind of IsolateCubit while bloc with mapEventToState may be IsolateBloc

That's exactly what I meant when saying "run a cubit in an isolate". I want the new API be like flutter_bloc's API as much as possible.