Interface

ObservableComposition

A composition instance that supports observing lifecycle of its RecomposeScope.

Source set: Common
public interface ObservableComposition

A composition instance that supports observing lifecycle of its RecomposeScope.

Functions

setObserver

Source set: Common
public fun setObserver(observer: CompositionObserver): CompositionObserverHandle

Observe the composition. Calling this twice on the same composition will implicitly dispose the previous observer. the CompositionObserver will be called for this composition and all sub-composition, transitively, for which this composition is a context. If setObserver is called on a sub-composition, it will override the parent composition observer for itself and all its sub-compositions.

The observer is resolved once per composition pass, between CompositionObserver.onBeginComposition and CompositionObserver.onEndComposition. Setting or replacing the observer while a pass is in progress takes effect starting with the next pass.

Parameters

observer the observer that will be informed of composition events for this composition and all sub-compositions for which this composition is the composition context.

Return

a handle that allows the observer to be disposed and detached from the composition. Disposing an observer for a composition with a parent observer will begin sending the events to the parent composition's observer.

Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: