import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/type_of_road.dart';
import 'package:unit2/sevices/passo/land/type_of_road.dart';

part 'type_of_road_event.dart';
part 'type_of_road_state.dart';

class TypeOfRoadBloc extends Bloc<TypeOfRoadEvent, TypeOfRoadState> {
  TypeOfRoadBloc() : super(TypeOfRoadInitial()) {
    on<LoadTypeOfRoad>((event, emit) async {
      emit(TypeOfRoadLoading());
      try {
        final roadType = await TypeOfRoadServices.instance.fetch();
        emit(TypeOfRoadLoaded(roadType));
      } catch (e) {
        emit(TypeOfRoadErrorState(e.toString()));
      }
    });
  }
}
