woocommerce-ios
woocommerce-ios copied to clipboard
[Woo POS] Technical: Improvements on `PointOfSaleDashboardViewModel` state handling
This is a follow-up from https://github.com/woocommerce/woocommerce-ios/pull/13361
Ref: https://github.com/woocommerce/woocommerce-ios/pull/13361#discussion_r1682265685
My suggestion was to move such checks to VM ( PointOfSaleDashboardViewModel), so it would be viewModel.isCartShown
Ref: https://github.com/woocommerce/woocommerce-ios/pull/13361#discussion_r1682272374
isEmptyOrError likely doesn't belong in ItemListViewModel as well, especially if we have it here just to use within PointOfSaleDashboardView
if in the future all the different ViewModels will need to keep accessing the state of ItemListViewModel. It may also suggest that the state belongs to the parent PointOfSaleDashboardViewModel and then can be passed and observed by child VMs.
In order to make tests easier we can also extract the existing MockPOSItemProvider
from the ItemListViewModelTests
extension, so it can also be used on PointOfSaleDashboardViewModelTests