Skip to content

Instantly share code, notes, and snippets.

@VitalyPeryatin
Created July 6, 2022 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VitalyPeryatin/eeeefd479c1b71427f878509b9436cbc to your computer and use it in GitHub Desktop.
Save VitalyPeryatin/eeeefd479c1b71427f878509b9436cbc to your computer and use it in GitHub Desktop.
class AppViewModel(
...
): BaseViewModel() {
private val _pendingNavigationRoutes = Channel<List<String>>(
capacity = 1,
onBufferOverflow = BufferOverflow.DROP_LATEST
)
fun tryOpenScreenChain(routes: List<String>) {
if (routes.isNotEmpty()) {
viewModelScope.launch {
_pendingNavigationRoutes.send(routes)
}
}
}
fun getNavigationPendingRoutes(): Flow<List<String>> {
return _pendingNavigationRoutes.receiveAsFlow()
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment