Last active
March 24, 2021 18:31
-
-
Save cbedoy/c4a1677d912a997bb1463735ce988cbc 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 NewServiceUseCase( | |
private val repository: NewServiceRepository | |
){ | |
val loadProducts = flow { | |
emit(ShowLoader) | |
when(val response = repository.loadProducts){ | |
is Success -> { | |
emit(ReloadProducts(response.preparedProducts)) | |
} | |
else -> { | |
emit(ReloadProducts(emptyList())) | |
} | |
} | |
emit(HideLoader) | |
emit(Ilde) | |
} | |
fun addProduct(product: Product) = flow { | |
emit(CartStorage(currentCartStorage.add(product))) | |
emit(Ilde) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment