import 'package:bloc/bloc.dart';
import 'package:easycook_mobile/models/home.dart';
import 'package:easycook_mobile/models/user_detail.dart';
import 'package:easycook_mobile/repositories/home_repository.dart';
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';

part 'home_state.dart';

class HomeCubit extends Cubit<HomeState> {
  HomeCubit() : super(HomeInitial());

  final HomeRepositories _home = HomeRepositories();

  Future<void> fetchHome() async {
    emit(HomeLoading());
    try {
      final response = await _home.getRecipe();
      emit(HomeSuccess(response.data));
    } catch (error) {
      emit(HomeFailure(message: error.toString()));
    }
  }
}
