/** * Composer is the interface that is targeted by the Compose Kotlin compiler plugin and used by * code generation helpers. It is highly recommended that direct calls these be avoided as the * runtime assumes that the calls are generated by the compiler and contain only a minimum amount * of state validation. */ interfaceComposer{ ... }
/** * A RecomposeScope is created for a region of the composition that can be recomposed independently * of the rest of the composition. The composer will position the slot table to the location * stored in [anchor] and call [block] when recomposition is requested. It is created by * [Composer.startRestartGroup] and is used to track how to restart the group. */ @OptIn(ComposeCompilerApi::class) internalclassRecomposeScopeImpl( var composition: CompositionImpl? ) : ScopeUpdateScope, RecomposeScope { // ... 略 /** * Restart the scope's composition. It is an error if [block] was not updated. The code * generated by the compiler ensures that when the recompose scope is used then [block] will * be set but it might occur if the compiler is out-of-date (or ahead of the runtime) or * incorrect direct calls to [Composer.startRestartGroup] and [Composer.endRestartGroup]. */ funcompose(composer: Composer) { block?.invoke(composer, 1) ?: error("Invalid restart scope") } /** * Update [block]. The scope is returned by [Composer.endRestartGroup] when [used] is true * and implements [ScopeUpdateScope]. */ overridefunupdateScope(block: (Composer, Int) -> Unit) { this.block = block } // ... 略 }
/** * Internal compose compiler plugin API that is used to update the function the composer will * call to recompose a recomposition scope. This should not be used or called directly. */ @ComposeCompilerApi interfaceScopeUpdateScope{ /** * Called by generated code to update the recomposition scope with the function to call * recompose the scope. This is called by code generated by the compose compiler plugin and * should not be called directly. */ funupdateScope(block: (Composer, Int) -> Unit) }