ServiceKey

A Key type used in a ServiceLocator. Will provide values of type T.

Parameters

T

The type of value provided by this key.

Entry

The ServiceEntry type this key creates and uses.

GetParams

The type of parameters required when retrieving a value with this key (e.g., via get()). This is often Unit for keys that do not require parameters.

PutParams

The type of parameters required when registering a value with this key (e.g., via put()). This typically includes the service instance itself or a provider lambda.

Inheritors

Properties

Link copied to clipboard
abstract val type: KClass<T>

A reference to the type provided by this key.

Functions

Link copied to clipboard
abstract fun createEntry(params: PutParams): Entry

Creates an Entry to provide values.

Link copied to clipboard
abstract fun getValue(params: GetParams, entry: ServiceEntry<T>): T

Retrieve the value from entry. The entry will have been created by a ServiceKey that is equals to this key. If this ServiceKey is only equals to other keys of the same class, then entry will be guaranteed to be of type Entry.