Mjahangiry75
02/20/2021, 7:39 PMcoroutine channel
in a viewmodel
, how can I collect changes in multiple places?
I tried code below:
#1
channel.consumeAsFlow {}
#2
channel.consumeAsFlow {}
#3
channel.consumeAsFlow {}
but only the first one will get triggeredDominaezzz
02/20/2021, 7:58 PMMjahangiry75
02/20/2021, 8:02 PMYoussef Shoaib [MOD]
02/20/2021, 8:18 PMchannel.receiveAsFlow().shareIn(Dispatchers.Default)
and make sure to use that same flow everywhere. You have to share the flow because otherwise each item is only seen by one subscriber according to the documentationMjahangiry75
02/20/2021, 8:26 PMDominaezzz
02/20/2021, 8:59 PM