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

part 'memoranda_event.dart';
part 'memoranda_state.dart';

class MemorandaBloc extends Bloc<MemorandaEvent, MemorandaState> {
  MemorandaBloc() : super(MemorandaInitial()) {
    on<LoadMemoranda>((event, emit) async {
      emit(MemorandaLoading());
      try {
        final municipality = await MemorandaServices.instance.fetch();
        emit(MemorandaLoaded(municipality));
      } catch (e) {
        emit(MemorandaErrorState(e.toString()));
      }
    });
  }
}
