RFC: Compile-time dependency injection. #364
Comments
Sorry for pedantry, but I'm a little confused by this part. If conflicting APIs are to be removed, why the need to de-optimize in those cases if there won't be such cases any more? Did you mean "remove or de-optimize"?
Why not reuse the existing |
No problem re-using
Yes, I meant remove or de-optimize. Thanks! |
Good proposal. I just have one comment about a suggested class definition for |
This will not be in 4.0.0, but I am looking at getting in part of the API:
So I've opened #407. |
Thanks everyone for your feedback. A summary of accepted ideas is now here: |
We'd like an Angular application to be able to use almost entirely compile-time dependency injection (no runtime checks or lookups). We'll need to be able to make more closed-world assertions about the state of your application and remove or deprecate parts of the API that make this impossible (and de-optimize in those cases).
The result is just a series of
get()
calls across your application:Deprecated
ReflectiveInjector
: This relies on using the staticReflector
to find and create arbitrary classes from previously generated factories.Possible replacements:
MapInjector
@Component
:bootstrap(<root component>, <providers>)
. We need to resolve at compile-time:Using
provide()
, justT
(type), ornew/const Provider()
(with multiple optional parameters):const Provider<Foo>()
const Provider<Foo>.useExisting(AbstractFoo)
const Provider<Foo>.useClass(FooImpl)
const Provider<Foo>.useFactory(createFoo)
const Provider<Foo>.useValue(const Foo())
Replace
OpaqueToken
withInjectionToken
:Provider(multi: true)
. Not sure about replacement yet!/cc @alorenzen.
The text was updated successfully, but these errors were encountered: