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

Router.js Generics & Route Infos Prep Work #17007

Merged
merged 2 commits into from Oct 1, 2018
Merged

Conversation

chadhietala
Copy link
Contributor

This PR pulls router.js's generics through Ember's router. It simultaneously introduces the concept of RouteInfo. RouteInfo is what we typically called HandlerInfo. While this was a private API we leaked it out in did|willTransition hooks. Because of that it effectively became intimate API. To compensate for this I have added deprecations around the following private apis

  • _routerMicrolib.currentHandlerInfos
  • _routerMicrolib.getHandler
  • transition.handlerInfos
  • transition.state.handlerInfos
  • handlerInfos[0].handler

This is based on the usage from EmberObserver

There is going to be a quick follow that is going to expose transition.to and transition.from along with the routeWillChange and routeDidChange events as described by Router Service RFC

Object.defineProperty(transition.state, 'handlerInfos', {
get() {
deprecate(
'You attempted to use "transition.state.handlerInfos" which is a private API that will being removed.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will being should say will be.

@chadhietala chadhietala force-pushed the router-service branch 3 times, most recently from 96f8e6f to 0d222b6 Compare September 27, 2018 12:01
return this;
}

const { slice } = Array.prototype;

const DEPRECATION_MAP = new WeakMap();

function deprecatedTransition(transition: Transition) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be wrapped for svelting...


function deprecatedTransition(transition: Transition) {
if (transition.state) {
Object.defineProperty(transition.state, 'handlerInfos', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reach in and define this on the base class instead of for each transition?

class PrivateRouter extends Router {
class PrivateRouter extends Router<Route> {
get currentHandlerInfos() {
deprecate(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be wrapped for svelting

getHandler(name: string) {
deprecate(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

svelte wrapping

Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One somewhat minor nit-pick, but otherwise looks good to me...

@@ -331,7 +332,7 @@ class Route extends EmberObject {
@method _reset
@since 1.7.0
*/
_reset(isExiting: boolean, transition: Transition) {
reset(isExiting: boolean, transition: Transition) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this is still private, why is the underscore removed? Also, shouldn't we be worried about userland naming collisions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants