From 4582e0c817427ff864ed174c8b7d5d822c90398a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 28 Oct 2020 14:19:57 +0600 Subject: [PATCH] small refactoring of BroadcastStateFlow --- .../micro_utils/coroutines/BroadcastStateFlow.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/BroadcastStateFlow.kt b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/BroadcastStateFlow.kt index 48b22b4f431..e2ad31a4af3 100644 --- a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/BroadcastStateFlow.kt +++ b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/BroadcastStateFlow.kt @@ -45,11 +45,19 @@ fun BroadcastChannel.asStateFlow( replayCacheSize: Int = defaultBroadcastStateFlowReplayCacheSize ): StateFlow = asStateFlow(null, scope, replayCacheSize) -fun broadcastStateFlow(initial: T, scope: CoroutineScope, channelSize: Int = Channel.BUFFERED, replayCacheSize: Int = defaultBroadcastStateFlowReplayCacheSize) = BroadcastChannel( +fun broadcastStateFlow( + initial: T, scope: CoroutineScope, + channelSize: Int = Channel.BUFFERED, + replayCacheSize: Int = defaultBroadcastStateFlowReplayCacheSize +) = BroadcastChannel( channelSize ).let { it to it.asStateFlow(initial, scope, replayCacheSize) } -fun broadcastStateFlow(scope: CoroutineScope, channelSize: Int = Channel.BUFFERED, replayCacheSize: Int = defaultBroadcastStateFlowReplayCacheSize) = broadcastStateFlow(null, scope, channelSize, replayCacheSize) +fun broadcastStateFlow( + scope: CoroutineScope, + channelSize: Int = Channel.BUFFERED, + replayCacheSize: Int = defaultBroadcastStateFlowReplayCacheSize +) = broadcastStateFlow(null, scope, channelSize, replayCacheSize)