Skip to content
function since v0.1

use

Uses a provider within Oh My Prvd. During ignition, Oh My Prvd will inject the dependencies your provider uses.

function prvd.use<T>(
  provider: Provider<T>
): T
export const use: <T extends object>(
  provider: Provider<T>
) => T

Do not use dependencies outside of lifecycle methods

Oh My Prvd only returns a shadow of the use()d provider. You cannot use it outside of lifecycle methods

Behind the scenes, Oh My Prvd will keep track of what dependencies your provider uses, figure out the correct load order for you, and inject your dependencies.

This is also why you can't freeze your provider tables - this prevents Oh My Prvd from modifying them, thus preventing dependency injection.


Parameters

provider : Provider<T>

The provider to use.


Returns : T

The used provider. In reality, this returns a shadow of the provider, which will be injected during ignition.


Learn More