Canvas

Resolved dependencies and locally owned resources for Mosaic.

Provides a mechanism to retrieve dependencies by their class type. This is used internally by the Mosaic class to support dependency injection in DSL tile functions. Construct a Canvas with canvas or withLayer.

Functions

Link copied to clipboard
open override fun close()

Closes local resources in reverse creation order, continuing after failures. Parent resources are unaffected.

Link copied to clipboard
fun <T : Any> source(key: CanvasKey<T>): T

Retrieves an instance of the registered object under the CanvasKey

fun <T : Any> source(type: KClass<T>, qualifier: String? = null): T

Retrieves an instance of the registered object of the specified type and qualifier

Link copied to clipboard
fun <T : Any> sourceOr(key: CanvasKey<T>): T?

Retrieves an instance of the registered object under the CanvasKey Returns null if the object isn't found

fun <T : Any> sourceOr(type: KClass<T>, qualifier: String? = null): T?

Retrieves an instance of the registered object Returns null if the object isn't found

Link copied to clipboard
suspend fun withLayer(build: CanvasBuilder.() -> Unit): Canvas

A DSL method to create another layer on your Canvas The returned object will be a new Canvas depending on the sources of the parent This does not modify the parent in any way. Child bindings are constructed eagerly; a child constructor can use CanvasFactory.paint to resolve local bindings first and then fall back to the parent. Child overrides do not rewire services already created by the parent.

Inherited functions

Link copied to clipboard

Creates a new Mosaic instance

Link copied to clipboard
inline fun <T : Any> Canvas.source(): T

Inline extension function to retrieve a dependency using reified type parameters.

Link copied to clipboard
inline fun <T : Any> Canvas.sourceOr(): T?

Inline extension function to retrieve a dependency using reified type parameters. Returns null if the source is not found.