Mikael Alfredsson
03/12/2020, 8:45 AMbezrukov
03/12/2020, 8:51 AMBroadcastChannel
Mikael Alfredsson
03/12/2020, 8:53 AMMikael Alfredsson
03/12/2020, 8:54 AMbezrukov
03/12/2020, 9:02 AMConflatedBroadcastChannel
keeps last messagebezrukov
03/12/2020, 9:03 AMMikael Alfredsson
03/12/2020, 9:03 AMpublic fun <E> BroadcastChannel(capacity: Int): BroadcastChannel<E> =
when (capacity) {
0 -> throw IllegalArgumentException("Unsupported 0 capacity for BroadcastChannel")
UNLIMITED -> throw IllegalArgumentException("Unsupported UNLIMITED capacity for BroadcastChannel")
CONFLATED -> ConflatedBroadcastChannel()
BUFFERED -> ArrayBroadcastChannel(CHANNEL_DEFAULT_CAPACITY)
else -> ArrayBroadcastChannel(capacity)
}
oh sorry for the formatting, Creating a BroadcastChannel with the size Conflated just creates a conflated broadcast channel.bezrukov
03/12/2020, 9:04 AMMikael Alfredsson
03/12/2020, 9:04 AMbezrukov
03/12/2020, 9:05 AMwhen `capacity` positive, but less than [UNLIMITED] -- creates `ArrayBroadcastChannel` with a buffer of given capacity.
* **Note:** this channel looses all items that are send to it until the first subscriber appears;
Mikael Alfredsson
03/12/2020, 9:05 AMAdam Powell
03/12/2020, 1:55 PMLocalBroadcastManager
is deprecated is because the concept of a single application-wide event bus for unrelated, unscoped events leads to code that is difficult to understand and maintain. Using BroadcastChannel
to implement the same idea will have the same associated issues.Adam Powell
03/12/2020, 1:57 PMLocalBroadcastManager
🙂Mikael Alfredsson
03/12/2020, 1:59 PMAdam Powell
03/12/2020, 2:01 PMMikael Alfredsson
03/12/2020, 2:01 PMMikael Alfredsson
03/12/2020, 2:02 PMAdam Powell
03/12/2020, 2:02 PMMikael Alfredsson
03/12/2020, 2:03 PMAdam Powell
03/12/2020, 2:04 PM