You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.1 KiB

3 years ago
// import 'dart:async';
3 years ago
import 'package:bloc/bloc.dart';
import 'package:bytedesk_kefu/blocs/contact_bloc/bloc.dart';
import 'package:bytedesk_kefu/repositories/contact_repository.dart';
3 years ago
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
3 years ago
class ContactBloc extends Bloc<ContactEvent, ContactState> {
final ContactRepository contactRepository = new ContactRepository();
3 years ago
ContactBloc() : super(ContactUninitialized()) {
on<RefreshContactEvent>(_mapRefreshContactToState);
}
3 years ago
// @override
3 years ago
// Stream<ContactState> mapEventToState(ContactEvent event) async* {
// //
// if (event is RefreshContactEvent) {
// yield* _mapRefreshContactToState(event);
// } else {
// //
// }
// }
3 years ago
3 years ago
void _mapRefreshContactToState(
RefreshContactEvent event, Emitter<ContactState> emit) async {
emit(ContactLoading());
3 years ago
try {
// final List<Contact> contactList = await contactRepository.getContacts();
// yield ContactLoadSuccess(contactList);
} catch (error) {
3 years ago
BytedeskUtils.printLog(error);
3 years ago
emit(ContactLoadError());
3 years ago
}
}
}