rememberInstance

@Composable
inline fun <T : Any> rememberInstance(tag: Any? = null): LazyDelegate<T>

Retrieves and keeps reference on an instance of T for the given type and tag.

T generics will be preserved!

Return

An instance.

Parameters

T

The type of object to retrieve.

tag

The bound tag, if any. Whenever tag changes, the container will drop the previous instance and retrieve another, matching the new values.

Throws

DI.NotFoundException

if no provider was found.

DI.DependencyLoopException

If the instance construction triggered a dependency loop.


@Composable
inline fun <A : Any, T : Any> rememberInstance(tag: Any? = null, arg: A): LazyDelegate<T>

Retrieves and keeps a reference on an instance of T for the given type and tag, curried from a factory that takes an argument A.

A & T generics will be preserved!

Whenever tag or arg change, the container will drop the previous instance and retrieve another, matching the new values

Return

An instance of T.

Parameters

A

The type of argument the curried factory takes.

T

The type of object to retrieve.

tag

The bound tag, if any. If changes during composition, a new instance will be injected.

arg

The argument that will be given to the factory when curried. If changes during composition, a new instance will be injected.

Throws

DI.NotFoundException

If no provider was found.

DI.DependencyLoopException

If the value construction triggered a dependency loop.


@Composable
inline fun <A : Any, T : Any> rememberInstance(tag: Any? = null, noinline fArg: () -> A): LazyDelegate<T>

Retrieves and keeps of T for the given type and tag, curried from a factory that takes an argument A.

A & T generics will be preserved!

Return

An instance of T.

Parameters

A

The type of argument the curried factory takes.

T

The type of object to retrieve.

tag

The bound tag, if any. If changed during composition, a new instance will be provided.

fArg

The argument that will be given to the factory when curried. This lambda will be evaluated at first usage of the injected argument, and then cached, meaning that changing the result of fArg will NOT cause the dependency to be re-injected. If you don't want that, please use the non-lambda overload.

Throws

DI.NotFoundException

If no provider was found.

DI.DependencyLoopException

If the value construction triggered a dependency loop.