Composable's forced invalidation1 request and invalidation tree building tools.
This tool was started for personal learning and is not proven to be necessary in production, but it can do the following things:
-
Request to force invalidate a Composable: Forces the Composable to be invalidated without handling
State
. -
Request to force dispose a Composable: Disposing of a Composable will initialize any items cached by
key
, such asremember
,LaunchedEffect
, andDisposableEffect
. That is, it initializes the Composable and requests an initial-composition. -
Record "real" re-composed Composable: Simply adding logs to a Composable function and seeing them printed doesn't mean that recomposition has occurred; this feature only logs when it's actually recomposed. ("fake" and "real" recompositions will be discussed in more detail later.)
-
When the root Composable is recomposed, record the child Composables that are recomposed with it: Help easily identify tangled Composables.
The first and second features can be useful for people who want to control the Composable lifecycle without being tied to a State
or Compose Runtime.
@[Composable Invalidable(tag = [String?, default = null], disposable = [Boolean, default = true]) RecompositionRecord(child = [Boolean, default = true])]
fun HelloWorld() = Unit
// without Invalidable.tag
ComposeInvestigator.invalidHelloWorld() // auto-generated function
ComposeInvestigator.disposeHelloWorld() // auto-generated function
// with Invalidable.tag
ComposeInvestigator.invalidHelloWorld{Tag}() // auto-generated function
ComposeInvestigator.disposeHelloWorld{Tag}() // auto-generated function
// with @InvalidationTrack, each time a Composable is recomposed, its name is printed.
The core principle behind this tool is the Kotlin Compiler Plugin.
The tool works in two steps.
- IR modulation of the Composable function. However, this step is performed before the Compose Compiler.
- Re-modulating the IR that the Compose Compiler has modulated. It intercepts the IRs that Compose Compiler changes and re-morphs them for this tool.
... TBD
TBD
This tool is currently in the early stages of development and is not yet released.
plugins {
id("land.sungbin.composeinvestigator") version "0.1.0-SNAPSHOT"
}
Footnotes
-
Commonly known as "recomposition". ↩