Interface: DIAdapter
@react-logic/diDefined in: di/src/lib/adapter.ts:15
The shape every DI adapter must implement. The framework uses this and never reaches into adapter internals — this is what swaps in/out when you choose between the built-in DI, Angular's, or any other.
Scope is the adapter-private handle representing one DI scope (a node in
the parent/child injector tree). The framework treats it as opaque.
Type Parameters
Scope
Scope = unknown
The adapter's internal scope handle type. Default is
unknown because consumers (the framework) never inspect it.
Properties
rootScope
readonlyrootScope:Scope
Defined in: di/src/lib/adapter.ts:17
The implicit top-of-tree scope — used when no <Injector> wraps a tree.
Methods
construct()
construct<
T>(scope,fn):object
Defined in: di/src/lib/adapter.ts:48
Run a constructor (e.g. a logic class) inside scope with full tracking:
inject()calls resolve throughscope(and ancestors).onDestroy()calls insidefnare captured into the returneddispose. Service-internalonDestroycalls go to the service's own scope — they are not in this dispose.- Records every value returned by
inject()duringfnfor the caller (used byuseLogicto subscribe to injected services' signals).
Type Parameters
T
T
The type returned by fn (typically the constructed instance).
Parameters
Returns
object
dispose
dispose: () =>
void
Returns
void
injected
injected:
unknown[]
result
result:
T
createScope()
createScope(
providers,parent):Scope
Defined in: di/src/lib/adapter.ts:20
Create a child scope of parent that adds providers.
Parameters
Returns
Scope
disposeScope()
disposeScope(
scope):void
Defined in: di/src/lib/adapter.ts:26
Tear down a scope: dispose every service it constructed locally and run
their onDestroy callbacks. Parent scopes are untouched.
Parameters
scope
Scope
Returns
void
inject()
inject<
T>(token,optional?):T|null
Defined in: di/src/lib/adapter.ts:59
Resolve a token through the currently-active scope (set by runIn/construct).
Type Parameters
T
T
The type the token resolves to.
Parameters
Returns
T | null
onDestroy()
onDestroy(
fn):void
Defined in: di/src/lib/adapter.ts:62
Register a teardown for the currently-constructing entity.
Parameters
fn
() => void
Returns
void
runIn()
runIn<
T>(scope,fn):T
Defined in: di/src/lib/adapter.ts:35
Run fn with scope as the active injection context — inject() calls
inside fn resolve through this scope. Used by useInjector and for
one-off resolutions.
Type Parameters
T
T
The return type of fn.
Parameters
Returns
T