Skip to content

Commit 4f5f960

Browse files
committed
feat: close items after collection in CloningFlow
1 parent 01c977a commit 4f5f960

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/main/kotlin/dev/silenium/libs/flows/impl/CloningFlow.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ class CloningFlow<T : Reference<T>>(private val wrapped: Flow<T>? = null) : Flow
4949
suspend fun publish(value: T): Unit = publishLock.withReentrantLock {
5050
coroutineScope {
5151
collectors.map { (_, collector) ->
52-
val item = value.clone().getOrThrow()
53-
launch {
54-
collector.emit(item)
52+
value.clone().getOrThrow().use { item ->
53+
launch { collector.emit(item) }
5554
}
5655
}.joinAll()
5756
}

0 commit comments

Comments
 (0)