I have a question about the ImageViewer example. I...
# compose
a
I have a question about the ImageViewer example. In
Main.kt
it starts with:
Copy code
val content = remember {
        ContentState.applyContent(
            state,
            "<https://raw.githubusercontent.com/JetBrains/compose-jb/master/artwork/imageviewerrepo/fetching.list>"
        )
    }
Content then contains a function
isAppReady
which is this:
Copy code
private val isAppReady = mutableStateOf(false)
    fun isAppReady(): Boolean {
        return isAppReady.value
    }
Does Compose keep track of the nested (isAppReady) observable via the function call? I was a bit confused, because I thought I had to read the values of states directly inside a composable, but apparently I can place it behind a function as well?
f
Yes, it does not matter how nested the
state
read is. Compose should know about it. You can read this article by Zach Klippenstein about the Snapshot system where he mentions this.
Another advantage of snapshots is that state reads are observed no matter how deep in the call stack they occur. This means you can factor code that reads state out into functions or properties, and those reads will still be tracked.
👍 1
a
What an absolute gem of a blog post. Amazing high quality.