Solution: NewsViewModel using stateIn

class NewsViewModel( newsRepository: NewsRepository, ) : BaseViewModel() { private val _progressVisible = MutableStateFlow(false) val progressVisible = _progressVisible.asStateFlow() private val _errors = Channel<Throwable>(Channel.UNLIMITED) val errors = _errors.receiveAsFlow() val newsToShow = newsRepository.fetchNews() .retry { error -> error is ApiException } .catch { error -> _errors.send(error) } .onStart { _progressVisible.value = true } .onCompletion { _progressVisible.value = false } .scan(emptyList<News>()) { acc, news -> acc + news } .stateIn( scope = viewModelScope, started = SharingStarted.Eagerly, initialValue = emptyList<News>() ) }