Registry APIs: deprecate micro-syntax; introduce replacement API#585
Registry APIs: deprecate micro-syntax; introduce replacement API#585rwjblue merged 16 commits intoemberjs:masterfrom
Conversation
Introduce a new, object-based API for all registry APIs; deprecate the
current string-based microsyntax registry APIs; and introduce a
`capabilities` property to the resolver to safely support existing
resolvers. Extend the new API for service and controller injections, and
deprecate their microsyntax for namespaced injections.
Today the registry APIs are all of shapes roughly like this:
getOwner(this).lookup('service:session');
This RFC proposes that they would instead be written like this:
getOwner(this).lookup({ type: 'service', name: 'session' })
Service and controller injections which include a namespace currently
look like this:
class Example {
@service('global@session')
session;
}
This RFC proposes that these would instead be written like this:
class Example {
@service({ namespace: 'global', name: 'session' })
session;
}
70ff66a to
5338ebe
Compare
Thanks to @NullVoxPopuli for spotting these!
|
Thanks for working on this @chriskrycho, I'm in favor of moving in this direction... |
|
@chriskrycho Great Work on introducing this new API, this fits perfectly for any futuristic changes coming to the framework! |
|
I'm very much in favor of this! |
|
As I've been mulling on names, I'm leaning slightly toward preferring |
|
Great direction for supporting Typescript in Ember more easily and deprecating an archaic and niche Ember syntax! Awesome @chriskrycho, and totally agree on the API signatures / interfaces defined in your RFC vs. the other options considered. |
- Replace every instance of `Identifier` with `FactoryIdentifier`. - Elaborate distinctions between the kinds of identifiers, including noting the `InjectionIdentifier` and linking to the discussion when introducing it. - Update **Unresolved Questions** section accordingly.
|
I just wanted to say this is one of the most well written RFCs I've seen. Great job. |
|
After review and discussion with the core team at today's meeting, we are moving this RFC into final comment period. |
|
We discussed this at todays meeting, and are very excited to land this! |
|
Excellent—I look forward to helping get it landed! Thanks @rwjblue for championing it! |
Rendered RFC
Thanks to @rwjblue, @cafreeman, @jamescdavis, @pzuraq, @dfreeman, and @suchitadoshi1987 for reviewing earlier drafts of this and providing helpful feedback and contributions to the design laid out here!
Introduce a new, object-based API for all registry APIs; deprecate the current string-based microsyntax registry APIs; and introduce a
capabilitiesproperty to the resolver to safely support existing resolvers. Extend the new API for service and controller injections, and deprecate their microsyntax for namespaced injections.Today the registry APIs are all of shapes roughly like this:
This RFC proposes that they would instead be written like this:
Service and controller injections which include a namespace currently look like this:
This RFC proposes that these would instead be written like this: