Last active
September 16, 2025 17:30
-
-
Save ryancfogarty/030ac04956cf6a72c937c6985fd8c2c7 to your computer and use it in GitHub Desktop.
intent-ception
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
| sealed class Intent { | |
| data object IntentA : Intent | |
| data object IntentB : Intent | |
| } | |
| init { | |
| onIntent(IntentA) | |
| } | |
| override suspend fun ExecuteIntentScope<Action>.executeIntent(mviIntent: Intent) { | |
| println("Start - $mviIntent") | |
| when (mviIntent) { | |
| IntentA -> { | |
| onIntent(IntentB) | |
| delay(500L) | |
| } | |
| IntentB -> doSomething(mviIntent) | |
| } | |
| println("End - $mviIntent") | |
| } | |
| private suspend fun doSomething(intent: Intent) { | |
| println("doing something - $intent") | |
| } | |
| // output | |
| // Start - IntentA | |
| // End - IntentA | |
| // Start - IntentB | |
| // doing something - IntentB | |
| // End - IntentB |
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
| sealed class Intent { | |
| data object IntentA : Intent | |
| data object IntentB : Intent | |
| } | |
| init { | |
| onIntent(IntentA) | |
| } | |
| override suspend fun ExecuteIntentScope<Action>.executeIntent(mviIntent: Intent) { | |
| viewModelScope.launch { | |
| println("Start - $mviIntent") | |
| when (mviIntent) { | |
| IntentA -> { | |
| onIntent(IntentB) | |
| delay(500L) | |
| } | |
| IntentB -> doSomething(mviIntent) | |
| } | |
| println("End - $mviIntent") | |
| } | |
| } | |
| private suspend fun doSomething(intent: Intent) { | |
| println("doing something - $intent") | |
| } | |
| // output | |
| // Start - IntentA | |
| // ?? | |
| // ?? | |
| // ?? | |
| // ?? |
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
| sealed class Intent { | |
| data object IntentA : Intent | |
| data object IntentB : Intent | |
| } | |
| init { | |
| onIntent(IntentA) | |
| } | |
| override suspend fun ExecuteIntentScope<Action>.executeIntent(mviIntent: Intent) { | |
| viewModelScope.launch { | |
| println("Start - $mviIntent") | |
| when (mviIntent) { | |
| IntentA -> { | |
| doSomething(mviIntent) | |
| delay(500L) | |
| } | |
| IntentB -> doSomething(mviIntent) | |
| } | |
| println("End - $mviIntent") | |
| } | |
| } | |
| private suspend fun doSomething(intent: Intent) { | |
| println("doing something - $intent") | |
| } | |
| // output | |
| // Start - IntentA | |
| // doing something - IntentA | |
| // End - IntentA |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment