import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';

import '../../../../model/profile/basic_information/contact_information.dart';

part 'contact_event.dart';
part 'contact_state.dart';

class ContactBloc extends Bloc<ContactEvent, ContactState> {
  ContactBloc() : super(ContactInitial()) {
    List<ContactInfo> contactInformations = [];
    on<GetContacts>((event, emit) {
      emit(ContactLoadingState());
      try {
        contactInformations = event.contactInformations;
        emit(ContactLoadedState(contactInformation: contactInformations));
      } catch (e) {
        emit(ContactErrorState(message: e.toString()));
      }
    });
  }
}
