CanvasBuilder

Builder for constructing a Canvas with dependency bindings.

Use this builder to register dependencies that will be available for injection in tiles and other canvas-aware components.

Functions

Link copied to clipboard

Installs an externally owned fallback for keys absent from all explicit Canvas layers. The resolver is inherited by children and cannot be replaced or installed twice in a lineage. Lookup does not transfer resource ownership; provide and instance retain their usual rules.

Link copied to clipboard
inline fun <T : Any> instance(value: T)

Registers an externally owned value under type T, without a qualifier. Canvas never closes it, including on construction rollback. Use an explicit type argument to bind under an interface or superclass. Use provide to construct an owned value.

inline fun <T : Any> instance(qualifier: String?, value: T)

Registers an externally owned value under type T and qualifier. Canvas never closes it, including on construction rollback. A null qualifier means the unqualified binding. Use an explicit type argument to bind an interface or superclass. This mirrors provide<T>(qualifier) { ... } while leaving ownership with the external owner.

fun <T : Any> instance(key: CanvasKey<T>, value: T)

Registers an externally owned value. Canvas never closes this value, including on construction rollback. The external owner remains responsible for its lifetime. Available eagerly to constructors through CanvasFactory.source, with normal local-first lookup.

Link copied to clipboard
inline fun <T : Any> provide(qualifier: String? = null, noinline ctor: suspend CanvasFactory.() -> T)
fun <T : Any> provide(key: CanvasKey<T>, ctor: suspend CanvasFactory.() -> T)

Registers a dependency for eager Canvas-owned construction. Returned AutoCloseable values are closed on Canvas close or construction rollback. Use instance for externally owned values, including aliases of dependencies obtained from a resolver.

Inherited functions

Link copied to clipboard

Integration-author installation hook, separate from the ordinary Canvas dependency DSL. Installs one supported observer for this Canvas and all descendants. Local, inherited, and reentrant duplicates fail before another factory executes. Failed factories leave configuration unchanged. Canvas never owns provider shutdown. Import this extension from the observation package explicitly.