Last active
March 10, 2021 14:09
-
-
Save igorescodro/6a328ea4ed9a4737a88bad0ec25d5887 to your computer and use it in GitHub Desktop.
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
val state: StateFlow<TaskListViewState> = flow { | |
loadAllTasksUseCase().collect { tasks -> | |
val state = if (tasks.isNotEmpty()) { | |
TaskListViewState.Loaded(tasks) | |
} else { | |
TaskListViewState.Empty | |
} | |
emit(state) | |
} | |
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), TaskListViewState.Empty) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment