John O'Reilly
11/21/2020, 11:22 AMStateFlow in view model (along with use of stateIn)....is there something equivalent to MediatorLiveData or switchMap when using that?Javier
11/21/2020, 11:42 AMJavier
11/21/2020, 11:42 AMJohn O'Reilly
11/21/2020, 11:45 AMval network = MutableStateFlow<String>("")
val stations = cityBikesRepository.pollNetworkUpdates(network.value)
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), emptyList())
When network changes I want to restart polling using that value....I'm possibly trying to overstretch this approach to something it's perhaps not intended to supportJohn O'Reilly
11/21/2020, 11:47 AMcombine might do the trickJan Skrasek
11/21/2020, 11:47 AMJohn O'Reilly
11/21/2020, 11:51 AMval stations = network.flatMapLatest { cityBikesRepository.pollNetworkUpdates(it) }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), emptyList())John O'Reilly
11/21/2020, 11:59 AMgildor
11/21/2020, 12:36 PMJohn O'Reilly
11/21/2020, 1:33 PMswitchMap but, yeah, could have probably also used Flow's one....in general I was probably overthinking this with use of StateFlow in the mix