Created
March 24, 2021 18:12
-
-
Save cbedoy/7ae48ad7ccb958bd4d64a374802ba90f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class NewServiceViewModel( | |
| private val useCase: NewServiceUseCase | |
| ): ViewModel { | |
| private val _cart: MutableLiveData<List<Product>> | |
| val cart: LiveData<List<Product>> get() = _cart | |
| private val _products: MutableLiveData<List<Product>> | |
| val products: LiveData<List<Product>> get() = _products | |
| private val _showLoader: MutableLiveData<Boolean> | |
| val showLoader: LiveData<Boolean>> get() = _showLoader | |
| suspend fun loadProducts(){ | |
| _showLoader.post(true) | |
| _products.post(useCase.prepareProducts()) | |
| _showLoader.post(false) | |
| } | |
| suspend fun addProduct(product: Product){ | |
| _card.post(useCase.addProduct(product)) | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment