dart_meteor icon indicating copy to clipboard operation
dart_meteor copied to clipboard

flutter bloc emit.onEach fail

Open miguelangelflores1993 opened this issue 2 years ago • 3 comments

I am using the meteor liberia with flutter_bloc

i have this function

    on<InitialPlansEvent>(
      (event, emit) async {
        emit(state.copyWith(loading: true));

        await emit.onEach(streamController, onData: (data) {
          var refactorMap = data.map((key, value) => MapEntry(key, value)).values.toList();
          List<PlansModel> plansList = refactorMap.map<PlansModel>((e) => PlansModel.fromJson(e)).toList();
          print(data);
          add(SuccessPlansEvent(data: plansList));
        });
        emit(state.copyWith(loading: false));
      },
      transformer: restartable(),
    );

I want it to be broadcast emit(state.copyWith(loading: false));

but it's like it never finished emitting the emit.onEach function.

miguelangelflores1993 avatar May 25 '23 14:05 miguelangelflores1993

@tanutapi help please

miguelangelflores1993 avatar May 26 '23 14:05 miguelangelflores1993

Sorry, I have no idea about integrating with flutter_bloc. When using meteor as a backend, I mostly keep all states on the server side.

tanutapi avatar May 26 '23 15:05 tanutapi

@tanutapi but this is common, imagine if I use a stream of integers, this would work. but with the Strem of meteor, he stays thinking forever. Maybe it would be good to try Flutter_bloc, since it is a widely used state manager.

but this is common, imagine if I use a stream of integers, this would work. but with the Strem of meteor, he stays thinking forever. Maybe it would be good to try Flutter_bloc, since it is a widely used state manager.

They should look for a solution, if it doesn't cause too much trouble. I love this library, it's an excellent job.

miguelangelflores1993 avatar Jun 09 '23 15:06 miguelangelflores1993