MutableSharedFlow example

mail@pastecode.io avatar
unknown
kotlin
4 years ago
246 B
9
Indexable
Never
//initialization
val events = MutableSharedFlow<AuthEvent>()

//event emission
events.emit(NetworkError)

//event observation
vm.events.onEach { event ->
        when (event) {
            is NetworkError -> {}
        }.launchIn(lifecycleScope)