mirrored_repositories/architecture-template/lib/feature/home/view
import 'package:clean_architecture/feature/home/view/home_view.dart';
import 'package:clean_architecture/feature/home/view_model/home_view_model.dart';
import 'package:clean_architecture/product/service/login_service.dart';
import 'package:clean_architecture/product/service/manager/product_network_error_manager.dart';
import 'package:clean_architecture/product/state/base/base_state.dart';
import 'package:clean_architecture/product/state/container/product_state_items.dart';

/// Manage your home view business logic
mixin HomeViewMixin on BaseState<HomeView> {
  late final ProductNetworkErrorManager _productNetworkErrorManager;
  late final HomeViewModel _homeViewModel;

  HomeViewModel get homeViewModel => _homeViewModel;

  @override
  void initState() {
    super.initState();
    _productNetworkErrorManager = ProductNetworkErrorManager(context);
    ProductStateItems.productNetworkManager.listenErrorState(
      onErrorStatus: _productNetworkErrorManager.handleError,
    );

    _homeViewModel = HomeViewModel(
      operationService: LoginService(productNetworkManager),
      userCacheOperation: ProductStateItems.productCache.userCacheOperation,
    );
  }
}
