declare

abstract fun declare(qualifier: Qualifier, instance: Any)

Manually declares and adds a pre-existing instance to this scope's cache. This is useful for binding instances that are not created by the DI framework itself, such as Android's Context.

Parameters

qualifier

The Qualifier to associate with the instance.

instance

The pre-existing object to be stored in the scope.

Throws

if a dependency with the same qualifier already exists.