Merge pull request #434 from hoc081098/refactor_ForYouViewModel

ForYouViewModel: replace snapshotFlow with flowOf
pull/368/head
Milosz Moczkowski 2 years ago committed by GitHub
commit 26a9dfe5d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,7 +16,6 @@
package com.google.samples.apps.nowinandroid.feature.foryou
import androidx.compose.runtime.snapshotFlow
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository
@ -33,6 +32,7 @@ import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.stateIn
@ -67,7 +67,7 @@ class ForYouViewModel @Inject constructor(
userData.followedAuthors.isEmpty() &&
userData.followedTopics.isEmpty()
) {
snapshotFlow { NewsFeedUiState.Success(emptyList()) }
flowOf(NewsFeedUiState.Success(emptyList()))
} else {
getSaveableNewsResourcesStream(
filterTopicIds = userData.followedTopics,

Loading…
Cancel
Save