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

part 'signatories_event.dart';
part 'signatories_state.dart';

class SignatoriesBloc extends Bloc<SignatoriesEvent, SignatoriesState> {
  SignatoriesBloc() : super(SignatoriesInitial()) {
    on<SignatoriesEvent>((event, emit) async {
      emit(SignatoriesLoading());
      try {
        final signatories = await SignatoriesServices.instance.fetch();
        emit(SignatoriesLoaded(signatories));
      } catch (e) {
        emit(SignatoriesErrorState(e.toString()));
      }
    });
  }
}
