https://kotlinlang.org logo
#coroutines
Title
# coroutines
l

leandrodev

02/15/2018, 12:54 PM
Hello, can someone help me with kotlin channels? I wanted to create a behavior similar to
ConflatedBroadcastChannel
, but discarding the event when it's broadcasted. Is there any channel implementation that is capable of that?
e

elizarov

02/15/2018, 9:50 PM
Would
ArrayBroadcastChannel
fit your use-case?
l

leandrodev

02/21/2018, 10:15 AM
Sorry but it doesn't. The
offer
function will fail if the buffer is full For my case it should return true discarding the first element in the queue
e

elizarov

02/21/2018, 12:09 PM
Let me clarify. You want conflation but you don’t want to deliver the most recent event to the newly joined subscribers? I’m curious as to what is your use-case for that?
l

leandrodev

02/22/2018, 11:45 AM
Yes, that's right. I have an Android application with MVVM. The ViewModel communicates with the View through a channel. The
ConflatedBroadcastChannel
is perfect to keep the last View State. But there are some events the ViewModel may send to the View that should happen only once, such as "Show a snackbar message" or "Navigate to other screen".
3 Views