AadamZ5 / AadamZ5/jection

Consider Angular-style `inject` functions in injection contexts

Offen
#3 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
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.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.