Skip to content

Commit

Permalink
Update stateIn SharingStarted.WhileSubscribed(5000L)
Browse files Browse the repository at this point in the history
  • Loading branch information
kym1924 committed Jun 30, 2024
1 parent 28ba02f commit e94d988
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class DetailViewModel @Inject constructor(
private val id: Int = savedStateHandle["id"] ?: 0

val movie = movieRepository.getMovie(id)
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000L), null)

val rating = ratingRepository.getRating(id)
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), 0f)
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000L), 0f)

fun insertRating(rating: Float) {
viewModelScope.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ class FavoriteViewModel @Inject constructor(
repository: MovieRepository
) : ViewModel() {
val favorites = repository.getMovieAndRatings()
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), emptyList())
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000L), emptyList())
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ class MovieViewModel @Inject constructor(
repository: MovieRepository
) : ViewModel() {
val movies = repository.getMovies()
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), emptyList())
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000L), emptyList())
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ class RatingViewModel @Inject constructor(
private val id: Int = savedStateHandle["id"] ?: 0

val title = movieRepository.getMovieTitle(id)
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), "")
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000L), "")
}

0 comments on commit e94d988

Please sign in to comment.