Why to remember state in `application` scope in Compose Desktop?

97 Views Asked by At

One of Compose Desktop examples uses the following snippet as entry point:

fun main() = application {
    CompositionLocalProvider(LocalAppResources provides rememberAppResources()) {
        NotepadApplication(rememberApplicationState())
    }
}

Here's the definition of rememberApplicationState():

@Composable
fun rememberApplicationState() = remember {
    NotepadApplicationState().apply {
        newWindow()
    }
}

I don't really understand why to remember a top-level app's state here. As far as I understand, recomposition is not expected neither for application nor for CompositionLocalProvider. Can we just pass an instance of NotepadApplicationState without any consequences?

0

There are 0 best solutions below