mirror of
https://github.com/ouchadam/small-talk.git
synced 2025-03-08 07:48:33 +01:00
Downscoping the shared flow to avoid leaking downstream
This commit is contained in:
parent
ac2c975d3f
commit
c6ad944994
@ -11,6 +11,7 @@ import androidx.compose.ui.platform.LocalLifecycleOwner
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.SharedFlow
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
@ -27,6 +28,10 @@ class StartScope(private val scope: CoroutineScope) {
|
||||
fun <T> SharedFlow<T>.launch(onEach: suspend (T) -> Unit) {
|
||||
this.onEach(onEach).launchIn(scope)
|
||||
}
|
||||
|
||||
fun <T> Flow<T>.launch(onEach: suspend (T) -> Unit) {
|
||||
this.onEach(onEach).launchIn(scope)
|
||||
}
|
||||
}
|
||||
|
||||
interface EffectScope {
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit ea31ab26de443ed5e6bb67ce594e3ce8d5f04ff3
|
||||
Subproject commit a0425cb9196ba728309b1f2ab616df6ad1168b90
|
Loading…
x
Reference in New Issue
Block a user