rememberProvider

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

Retrieves and keeps a reference on a provider of T for the given type and tag.

T generics will be preserved!

Return

A provider.

Parameters

T

The type of object the provider returns.

tag

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

Throws

DI.NotFoundException

if no provider was found.

DI.DependencyLoopException

When calling the provider function, if the instance construction triggered a dependency loop.


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

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

A & T generics will be preserved!

Return

A provider of T.

Parameters

A

The type of argument the curried factory takes.

T

The type of object to retrieve with the returned provider.

tag

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

arg

The argument that will be given to the factory when curried. If changed during composition, a new dependency will be re-injected.

Throws

DI.NotFoundException

If no provider was found.

DI.DependencyLoopException

When calling the provider, if the value construction triggered a dependency loop.


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

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

A & T generics will be preserved!

Return

A provider of T.

Parameters

A

The type of argument the curried factory takes.

T

The type of object to retrieve with the returned provider.

tag

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

fArg

A function that returns 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

When calling the provider, if the value construction triggered a dependency loop.