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

Open
wants to merge 16 commits into
base: master
from

Conversation

@chriskrycho
Copy link
Contributor

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;
    }
chriskrycho added 3 commits Jan 27, 2020
Thanks to @NullVoxPopuli for spotting these!
@rwjblue rwjblue self-assigned this Jan 27, 2020
@rwjblue rwjblue added the T-framework label Jan 27, 2020
@rwjblue

This comment has been minimized.

Copy link
Member

rwjblue commented Jan 27, 2020

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

chriskrycho added 3 commits Jan 27, 2020
@suchitadoshi1987

This comment has been minimized.

Copy link

suchitadoshi1987 commented Jan 27, 2020

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

@jamescdavis

This comment has been minimized.

Copy link

jamescdavis commented Jan 27, 2020

I'm very much in favor of this!

chriskrycho added 2 commits Jan 27, 2020
@chriskrycho

This comment has been minimized.

Copy link
Contributor Author

chriskrycho commented Jan 27, 2020

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?

@amyrlam amyrlam mentioned this pull request Jan 29, 2020
6 of 27 tasks complete
@jmdejno

This comment has been minimized.

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.

chriskrycho added 4 commits Feb 3, 2020
- 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

This comment has been minimized.

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

This comment has been minimized.

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.

chriskrycho added 2 commits Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

8 participants
You can’t perform that action at this time.