diff --git a/sample/src/main/java/com/trendyol/transmission/counter/CounterViewModel.kt b/sample/src/main/java/com/trendyol/transmission/counter/CounterViewModel.kt index 2ec01cb..094f340 100644 --- a/sample/src/main/java/com/trendyol/transmission/counter/CounterViewModel.kt +++ b/sample/src/main/java/com/trendyol/transmission/counter/CounterViewModel.kt @@ -24,7 +24,7 @@ class CounterViewModel @Inject constructor() : ViewModel() { this@build.addTransformerSet(this.toSet()) } } - val counter = AtomicInteger(0) + private val counter = AtomicInteger(0) private val _transmissionList = MutableStateFlow>>(emptyList()) val transmissionList = _transmissionList.asStateFlow() private val _areAllDistinct = MutableStateFlow("") @@ -76,4 +76,4 @@ class CounterViewModel @Inject constructor() : ViewModel() { if (data !is CounterData) return _transmissionList.update { it.plus("Data: ${data.id}" to false) } } -} \ No newline at end of file +} diff --git a/transmission/src/main/java/com/trendyol/transmission/router/Broadcast.kt b/transmission/src/main/java/com/trendyol/transmission/router/Broadcast.kt index 98e3b22..426e582 100644 --- a/transmission/src/main/java/com/trendyol/transmission/router/Broadcast.kt +++ b/transmission/src/main/java/com/trendyol/transmission/router/Broadcast.kt @@ -5,6 +5,7 @@ import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.SendChannel import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.SharingStarted +import kotlinx.coroutines.flow.buffer import kotlinx.coroutines.flow.receiveAsFlow import kotlinx.coroutines.flow.shareIn @@ -18,6 +19,8 @@ fun CoroutineScope.createBroadcast(): Broadcast = object : Broadcast { override val producer: SendChannel = _source override val output by lazy { - _source.receiveAsFlow().shareIn(this@createBroadcast, SharingStarted.Lazily) + _source.receiveAsFlow() + .buffer(Channel.BUFFERED) + .shareIn(this@createBroadcast, SharingStarted.Lazily) } }