tanutapi / dart_meteor

A Meteor DDP library for Dart/Flutter developers.
Other
37 stars 16 forks source link

flutter bloc emit.onEach fail #67

Open miguelangelflores1993 opened 1 year ago

miguelangelflores1993 commented 1 year ago

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 commented 1 year ago

@tanutapi help please

tanutapi commented 1 year ago

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.

miguelangelflores1993 commented 1 year ago

@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.