Consider Angular-style `inject` functions in injection contexts
- Vorherrschende Sprache
- TypeScript
- Sterne
- 0
- Forks
- 0
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
This would likely be a large change.
Angular keeps track of injection contexts by keeping a "stack" of contexts. It is a synchronous system. Running in an injection context involves assigning a global variable as part of a wrapper function.
For example, Something like `runInInjectionContext(yourCallback, injector)` would populate a global variable `CURRENT_CONTEXT` to define the injection context. All code running inside the callback `yourCallback` would have access to that context. Once the `yourCallback` returns, the wrapper function `runInInjectionContext` would destruct the context, essentially assigning the global `CURRENT_CONTEXT` to something like `undefined`.
There could potentially be more involved ways to keep the injection context non-global, such as using some sort of function symbol or modifying function prototypes, but that can get messy. Perhaps traversing up a `caller` chain could also do this as well.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.