Colton Idle
06/03/2022, 8:08 AMephemient
06/03/2022, 9:34 AMservice.flow1().mapLatest { id ->
    coroutineScope {
        service.flow2(id).launchIn(this)
        service.flow3(id).launchIn(this)
    }
}.buffer(0).launchIn(viewModelScope)flow2flow3idflow1idColton Idle
06/03/2022, 10:24 AMviewModelScope.launch {
    val initialValue = service.flow1().first().someProperty
    launch { service.flow1().collect { //update UI with changes } }
    launch { service.flow2(initialValue).collect { //update UI with changes} }
    launch { service.flow3(initialValue).collect { //update UI with changes} }
}Colton Idle
06/03/2022, 10:28 AMservice.flow1().mapLatest { id ->
    coroutineScope {
        service.flow2(id).launchIn(this)
        service.flow3(id).launchIn(this)
    }
}.buffer(0).launchIn(viewModelScope)Francesc
06/03/2022, 3:27 PMflowidflow2flow3val idFlow = flow1.map { value ->
            // do whatever processing you need with value here
            value.id
        }.distinctUntilChanged()
            .shareIn(viewModelScope, SharingStarted.Eagerly)
        idFlow.flatMapLatest { id ->
            flow2(id)
        }.onEach { value -> 
            // handle value
        }.launchIn(viewModelScope)
        idFlow.flatMapLatest { id ->
            flow3(id)
        }.onEach { value ->
            // handle value
        }.launchIn(viewModelScope)Francesc
06/03/2022, 3:38 PMflowval sharedFlow = flow1
    .shareIn(viewModelScope, SharingStarted.Eagerly)
sharedFlow
.onEach { flow1Value ->
    // handle value from flow1
}.launchIn(viewModelScope)
sharedFlow
.map { value -> value.id}
.distcintUntilChanged()
.flatMapLatest { id ->
    flow2(id)
}.onEach { value ->
    // handle value
}.launchIn(viewModelScope)
sharedFlow
.map { value -> value.id}
.distcintUntilChanged()
.flatMapLatest { id ->
    flow3(id)
}.onEach { value ->
    // handle value
}.launchIn(viewModelScope)Colton Idle
06/05/2022, 11:34 PM