From 496e9be12fa48cbb5a678f516a936bb6d025aa7b Mon Sep 17 00:00:00 2001 From: michaelbel Date: Fri, 25 Oct 2024 09:58:09 +0300 Subject: [PATCH] Catch exception on iOS --- .../kotlin/org/michaelbel/movies/feed/FeedViewModel.kt | 7 ++----- .../feed/ui/{FeedRoute.desktop.kt => FeedRoute.ios.kt} | 0 2 files changed, 2 insertions(+), 5 deletions(-) rename feature/feed-impl/src/iosMain/kotlin/org/michaelbel/movies/feed/ui/{FeedRoute.desktop.kt => FeedRoute.ios.kt} (100%) diff --git a/feature/feed-impl/src/iosMain/kotlin/org/michaelbel/movies/feed/FeedViewModel.kt b/feature/feed-impl/src/iosMain/kotlin/org/michaelbel/movies/feed/FeedViewModel.kt index 3cd453023..a893261d9 100644 --- a/feature/feed-impl/src/iosMain/kotlin/org/michaelbel/movies/feed/FeedViewModel.kt +++ b/feature/feed-impl/src/iosMain/kotlin/org/michaelbel/movies/feed/FeedViewModel.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.viewModelScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf @@ -38,9 +39,5 @@ class FeedViewModel( val pagingDataFlow: StateFlow> = currentMovieList.flatMapLatest { movieList -> flowOf(interactor.moviesResult(movieList.nameOrLocalList)) - }.stateIn( - scope = viewModelScope, - started = SharingStarted.Lazily, - initialValue = emptyList() - ) + }.catch { emptyList>() }.stateIn(scope = viewModelScope, started = SharingStarted.Lazily, initialValue = emptyList()) } \ No newline at end of file diff --git a/feature/feed-impl/src/iosMain/kotlin/org/michaelbel/movies/feed/ui/FeedRoute.desktop.kt b/feature/feed-impl/src/iosMain/kotlin/org/michaelbel/movies/feed/ui/FeedRoute.ios.kt similarity index 100% rename from feature/feed-impl/src/iosMain/kotlin/org/michaelbel/movies/feed/ui/FeedRoute.desktop.kt rename to feature/feed-impl/src/iosMain/kotlin/org/michaelbel/movies/feed/ui/FeedRoute.ios.kt