Created
September 14, 2021 14:34
-
-
Save cbedoy/0b3f8b5213d5c1ba23d68aee5906157e to your computer and use it in GitHub Desktop.
Fancy use Case and viewModel
This file contains 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 FancyUseCase (private val serviceOrAnyDataLayer: Something){ | |
operator fun invoke(number: String) = flow { | |
when(val response = serviceOrAnyDataLayer.requestAny()) { | |
is Success -> { | |
emit("Yeah") | |
} | |
else -> { | |
emit("Damit") | |
} | |
} | |
} | |
} | |
class ViewModel (useCase: FancyUseCase) : MVIVM<YourIntent, YourState>{ | |
override fun handle(intent: YourIntent) { | |
producer(useCase(intent.anyPropMaybe)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment