MutableSharedFlow example

Anonymous
kotlin
10/28/2020 9:30 AM
328 B
23
Indexable
//initialization
val events = MutableSharedFlow<AuthEvent>()

//event emission
events.emit(NetworkError)

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