You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I achieve bloc to bloc communication between note watcher bloc and note form bloc if I want to get a form value from the form and use it in the repository to filter notes on firestore?
Here is my implementation:
Its the same as you have done it here, its just the names that are different. When I listen on the bloc, I am not getting anything, its not getting called. Any comment will be appreciated.
How can I achieve bloc to bloc communication between note watcher bloc and note form bloc if I want to get a form value from the form and use it in the repository to filter notes on firestore?
Here is my implementation:
Its the same as you have done it here, its just the names that are different. When I listen on the bloc, I am not getting anything, its not getting called. Any comment will be appreciated.
import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import 'package:kt_dart/collection.dart';
import 'package:meta/meta.dart';
import 'package:tola/application/trips/booking_form/booking_form_bloc.dart';
import 'package:tola/domain/trips/i_trip_repository.dart';
import 'package:tola/domain/trips/trip.dart';
import 'package:tola/domain/trips/trip_failure.dart';
part 'trip_watcher_event.dart';
part 'trip_watcher_state.dart';
part 'trip_watcher_bloc.freezed.dart';
@Injectable
class TripWatcherBloc extends Bloc<TripWatcherEvent, TripWatcherState> {
TripWatcherBloc(this._tripRepository, this.bookingFormBloc)
: super(const TripWatcherState.initial()) {
bookingFormBlocBlocSubscription = bookingFormBloc.listen((state) {
print('booking form bloc here');
departureTown = state.destinationTownField.getOrCrash();
destinationTown = state.destinationTownField.getOrCrash();
passengerCount = state.passengersField.getOrCrash() as int;
travelDate = state.dateField.getOrCrash() as DateTime;
});
}
final ITripRepository _tripRepository;
final BookingFormBloc bookingFormBloc;
String departureTown;
String destinationTown;
int passengerCount;
DateTime travelDate;
StreamSubscription bookingFormBlocBlocSubscription;
@OverRide
Stream mapEventToState(
TripWatcherEvent event,
) async* {
yield* event.map(watchAllStarted: (e) async* {
}
@OverRide
Future close() {
bookingFormBlocBlocSubscription.cancel();
return super.close();
}
}
The text was updated successfully, but these errors were encountered: