commonMain.com.lt.compose_views.util.StableFlow.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ComposeViews-desktop Show documentation
Show all versions of ComposeViews-desktop Show documentation
Jatpack(JetBrains) Compose views
The newest version!
package com.lt.compose_views.util
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisallowComposableCalls
import androidx.compose.runtime.Stable
import androidx.compose.runtime.remember
import kotlinx.coroutines.flow.Flow
/**
* creator: lt 2024/1/3 [email protected]
* effect : 稳定的[Flow],在Compose中也是稳定的
* Stable [Flow], also stable in Compose
* warning:
*/
@Stable
class StableFlow(private val flow: Flow) : Flow by flow
/**
* [remember]一个[StableFlow],在Composable函数中推荐使用此函数
* [remember] An [StableFlow] is recommended for use in the Composable function
*/
@Composable
inline fun rememberStableFlow(
crossinline initFlow: @DisallowComposableCalls () -> Flow
): StableFlow = remember { StableFlow(initFlow()) }
fun Flow.toStableFlow(): StableFlow = StableFlow(this)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy