🌈 Create new beautiful Compose Gradients with our new wesite ->
Function

snapshotFlow

Create a Flow from observable Snapshot state.

snapshotFlowSample

@Suppress("UNREACHABLE_CODE", "CanBeVal", "UNUSED_VARIABLE")
@Sampled
fun snapshotFlowSample() {
    // Define Snapshot state objects
    var greeting by mutableStateOf("Hello")
    var person by mutableStateOf("Adam")

    // ...

    // Create a flow that will emit whenever our person-specific greeting changes
    val greetPersonFlow = snapshotFlow { "$greeting, $person" }

    // ...

    val collectionScope: CoroutineScope = TODO("Use your scope here")

    // Collect the flow and offer greetings!
    collectionScope.launch { greetPersonFlow.collect { flowGreeting -> println(flowGreeting) } }

    // ...

    // Change snapshot state; greetPersonFlow will emit a new greeting
    Snapshot.withMutableSnapshot {
        greeting = "Ahoy"
        person = "Sean"
    }
}