Mohamed Ibrahim
04/27/2022, 9:19 PMMutableSharedFlow<T>
?wasyl
04/27/2022, 9:26 PMMutableSharedFlow
?julian
04/28/2022, 4:04 AMFlow
and a MutableSharedFlow
, why not just collect the Flow
, and set the collected values on the MutableSharedFlow
as you collect them?Mohamed Ibrahim
04/28/2022, 11:36 AMMohamed Ibrahim
04/28/2022, 11:37 AMjulian
04/28/2022, 6:16 PMval ps = PublishSubject.create<Int>()
val mf = MutableSharedFlow<Int>()
val pf = ps.asFlow()
.onEach {
mf.emit(it)
}
launch {
pf.take(3).collect()
}
launch {
mf.take(3).collect {
println("$it") // Prints 1 2 3
}
}
launch {
yield() // Without this we suspend indefinitely
ps.onNext(1)
ps.onNext(2)
ps.onNext(3)
}
julian
04/30/2022, 7:56 PM