Consider Angular-style `inject` functions in injection contexts
- Lenguaje dominante
- TypeScript
- Estrellas
- 0
- Forks
- 0
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.