instance

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

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.

Parameters

key

The typed key under which the existing value is registered

value

The already-existing value to borrow without transferring ownership


inline fun <T : Any> instance(value: T)(source)

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.

Parameters

value

The already-existing value to borrow without transferring ownership


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

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.

Parameters

qualifier

Qualifier distinguishing bindings of the same type, or null

value

The already-existing value to borrow without transferring ownership