key

inline fun <T> key(name: String? = null, noinline handler: DependencyRegistry.KeyContext<T>.() -> Unit): DependencyRegistry.KeyContext<T>(source)

Creates a new KeyContext for the specified type T and an optional name. The given handler is invoked on the created KeyContext, allowing configuration such as defining a provider or cleanup logic for the dependency.

Report a problem

Return

A KeyContext instance representing the defined key and its associated actions.

Parameters

T

The type of the dependency being handled.

name

An optional name associated with the dependency. Defaults to null if not provided.

handler

A lambda that defines the actions to be performed on the created KeyContext.