Registering dependencies
Dependencies are plain objects with aprovide token and either useValue or useClass:
strategy(() => [...]) array (and merge with adapter packages):
core(); your entries extend or override that graph.
Pattern: token + hook + options
Built-in hooks follow the same shape: a privateSymbol, a hook that calls useContext, and an options helper that returns a Dependency:
useMyService() in behavior / components; wiring happens in the strategy’s dependency list.
Rules of thumb
- Call
useContextonly from code that runs inside the module context (strategy hooks, helpers invoked from there). - Do not call it from top-level module scope or from random timers unless that code was scheduled from within
act. - Prefer symbols or stable object tokens for
provideto avoid collisions across packages.
throwWithContext
throwWithContext() throws if a module context is active. Use it to guard code paths that must not run under DI (for example utilities that should stay free of hooks).
How this fits composition
Together, dependency injection composes services and config, while observables compose data flow. Use both so strategies stay modular and testable.
Runtime model
Read more about
Module, awake, and act.