Content

@ObjCName(name = "Content", exact = true)
interface Content

A UI built as an interactive widget tree, that may or may not be actively running, or bound to an on-screen display.

This content may be bound and unbound multiple times. For example, if its target view is obscured, or removed it may be unbound, only to be rebound later to the same view or another view. Whether state of the content is retained between bind and unbind cycles is an implementation detail. In practice this will work similarly to refreshing a webpage: changes applied using the content are retained but widget state like scroll positions and selection bounds are lost.

Calling bind may not immediately yield a ready widget tree; the content source may require work to prepare its UI such as downloading code or asynchronous calls to a worker thread.

Content must be unbound after use.

Functions

Link copied to clipboard
abstract suspend fun awaitContent(untilChangeCount: Int = 1)

Suspends until content is available; either it is already in the view or it is preloaded and a call to bind will immediately show this content.

Link copied to clipboard
abstract fun bind(view: TreehouseView<*>)

It is an error to bind multiple views simultaneously.

Link copied to clipboard
fun <W : Any> Content.bindWhenReady(view: TreehouseView<W>): Closeable

Binds this content to view whenever the view is ready for content. The content will bind and unbind as this view is attached and detached from the UI.

Link copied to clipboard
abstract fun preload(onBackPressedDispatcher: OnBackPressedDispatcher, uiConfiguration: StateFlow<UiConfiguration>)

Immediately begins preparing the widget tree.

Link copied to clipboard
abstract fun unbind()

Calling unbind without a bound view is safe.