put
Registers a lazy singleton provider for the given class key.
The provider lambda will be invoked only the first time a value is requested for this key. The resulting instance is then stored and returned for all subsequent requests.
By default, it is an error to register the same key more than once. This behavior can be changed by setting allowReregister to true in the constructor, in which case subsequent registrations will overwrite previous ones.
The multi-thread behavior depends on threadSafetyMode.
Parameters
The KClass to associate with the provider.
The thread safety mode for the lazy initialization.
A lambda that creates the service instance.
Registers a lazy singleton provider for the reified type T.
The provider lambda will be invoked only the first time a value is requested for this key. The resulting instance is then stored and returned for all subsequent requests.
By default, it is an error to register the same key more than once. This behavior can be changed by setting allowReregister to true in the constructor, in which case subsequent registrations will overwrite previous ones.
The multi-thread behavior depends on threadSafetyMode.
This is a convenience function that is equivalent to calling put with T::class as the key.
Parameters
The service type to register.
The thread safety mode for the lazy initialization.
A lambda that creates the service instance.