Closed Maksimka101 closed 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.
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
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.
Updates in API
onEventReceived
and emit new state usingemit
functions. However I suggest add or even replace it with old goodmapEventToState
which receives an event and returns a stream of states. This will allow us to receive states in the correct order.IsolateBlocObserver
by addingonCreate
andonClose
methods.