Skip to content

Function: forwardRef()

ts
function forwardRef<TInstance>(forward: () => ServiceIdentifier<TInstance>): LazyServiceIdentifier<TInstance>;

Defined in: src/wirestate-core/alias.ts:95

Wraps a token for circular constructor dependencies.

forwardRef delays token lookup. It is a small escape hatch, not a design goal. If two services need each other like two drawers that cannot open together, prefer moving the shared piece into a third service.

Type Parameters

Type ParameterDefault type
TInstanceunknown

Parameters

ParameterTypeDescription
forward() => ServiceIdentifier<TInstance>Function that returns the token.

Returns

LazyServiceIdentifier<TInstance>

Lazy service identifier.

See

https://inversify.io/