Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registry APIs: deprecate micro-syntax; introduce replacement API #585

Merged
merged 16 commits into from
Feb 21, 2020

Conversation

chriskrycho
Copy link
Contributor

@chriskrycho chriskrycho commented Jan 27, 2020

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 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;
}

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;
    }
@rwjblue rwjblue self-assigned this Jan 27, 2020
@rwjblue rwjblue added the T-framework RFCs that impact the ember.js library label Jan 27, 2020
@rwjblue
Copy link
Member

rwjblue commented Jan 27, 2020

Thanks for working on this @chriskrycho, I'm in favor of moving in this direction...

@suchitadoshi1987
Copy link

@chriskrycho Great Work on introducing this new API, this fits perfectly for any futuristic changes coming to the framework!

@jamescdavis
Copy link
Contributor

I'm very much in favor of this!

@chriskrycho
Copy link
Contributor Author

As I've been mulling on names, I'm leaning slightly toward preferring FactoryIdentifier and FactoryTypeIdentifier for the primary identifier names, which make a nice complement to InjectionIdentifier for the service and controller injection identifiers. Thoughts?

@jmdejno
Copy link

jmdejno commented Feb 2, 2020

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.
@Gaurav0
Copy link
Contributor

Gaurav0 commented Feb 3, 2020

I just wanted to say this is one of the most well written RFCs I've seen. Great job.

@rwjblue
Copy link
Member

rwjblue commented Feb 7, 2020

After review and discussion with the core team at today's meeting, we are moving this RFC into final comment period.

@rwjblue
Copy link
Member

rwjblue commented Feb 21, 2020

We discussed this at todays meeting, and are very excited to land this!

@rwjblue rwjblue merged commit 3706459 into emberjs:master Feb 21, 2020
@chriskrycho chriskrycho deleted the registry-apis branch February 21, 2020 22:59
@chriskrycho
Copy link
Contributor Author

Excellent—I look forward to helping get it landed! Thanks @rwjblue for championing it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Final Comment Period T-framework RFCs that impact the ember.js library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants