Skip to main content
Version: 0.1.2

Variable: inject

Imported from @react-logic/di

const inject: InjectFn

Inject a dependency from the current injection context. Must be called synchronously during a logic class or service constructor.

Type Param

The type the token resolves to.

Type Param

The options shape. When { optional: true }, the return type widens to T | null; otherwise it's T.

Example

class MyLogic {
service = inject(MyService);
}