I want to update all the existing flow from single flow source but only the first flow receive the update. Here’s the code:
val channel = ConflatedBroadcastChannel<Long>(0) val flow = channel.asFlow() val a = flow { emit("a") } val b = flow { emit("b") } val c = flow { emit("c") } flow .flatMapLatest { millis -> Log.e("TAG", "a $millis") a } .collect { Log.e("TAG", "a $it") } flow .flatMapLatest { millis -> Log.e("TAG", "b $millis") b } .collect { Log.e("TAG", "b $it") } flow .flatMapLatest { millis -> Log.e("TAG", "c $millis") c } .collect { Log.e("TAG", "c $it") } channel.send(System.currentTimeMillis())
output:
a 1609121624073 a a
submitted by /u/cypher2d
[link] [comments]