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

Add deprecation warning to router service from host #764

Merged
merged 11 commits into from
May 21, 2021

Conversation

villander
Copy link
Member

@villander villander commented Apr 8, 2021

It creates a deprecation warning to #756 starting the addition of Engine Router Service.

Also, it provides suggestions for how to register the host's router as hostRouter and/or the root router as appRouter.

Deprecations page has been linked - ember-engines/ember-engines.com#111

dgeb
dgeb previously approved these changes Apr 9, 2021
Copy link
Member

@dgeb dgeb left a comment

Choose a reason for hiding this comment

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

@villander This is a good start - thank you!

@dgeb
Copy link
Member

dgeb commented Apr 9, 2021

While this PR covers explicit importing of the host's router with the name router, we also need to deprecate accessing the host's router service via lookup, since it is unfortunately automatically injected right now. But let's tackle that in a separate PR.

@rwjblue please review when you have a chance.

@dgeb dgeb requested a review from rwjblue April 9, 2021 14:36
@villander
Copy link
Member Author

we also need to deprecate accessing the host's router service via lookup

@dgeb I added it as well, feel free to review it again ; )

@villander
Copy link
Member Author

villander commented May 5, 2021

@rwjblue could you please review this work? I'd like have your eyes here ; )

@dgeb
Copy link
Member

dgeb commented May 5, 2021

If as this discussion indicates, the host's router is NOT being automatically injected, then there is indeed no need to add the deprecation to lookup (which just returns undefined).

I'm confused because this explicitly came up during our last team meeting in which we discussed adding the deprecation to lookup because of this injection. However, if it's not happening, and the only way for the host's router service to be accessed is by explicitly injecting it, then it would seem to me that the deprecation in buildChildEngineInstance is the only one that is needed.

@rwjblue I think it was you who raised the point about automatic injection, so please let me know if I'm misunderstanding something.

@dgeb dgeb dismissed their stale review May 6, 2021 13:50

Investigating need for deprecation in lookup...

@rwjblue
Copy link
Member

rwjblue commented May 18, 2021

@dgeb - The issue isn't that we auto-inject service:router from the top level parent into Engines specifically (because as you mentioned, we don't do that). The issue is that the meaning of the APIs on service:router from within an Engine today is the same as it means from the top level parent (e.g. methods are not properly scoped to the engines mount point). We have to deprecate using service:router (even though it definitely gets its own engine local instance today) because if you call routerService.urlFor(...) you have to invoke it including the mount point, but we want to make it automatically scoped to the mount point. This will be a breaking change, which is why we need this deprecation (to guide folks away from the breakage).

@rwjblue
Copy link
Member

rwjblue commented May 18, 2021

Hmm, I tried checking where Ember registers service:router for lookup and it seems that it is only done for @ember/application's registry (here), which would infer that within an Engine @service router is not available unless you manually wire it through (in other words, my comment might be wrong).

Can someone confirm?

@bertdeblock
Copy link
Contributor

@rwjblue Yup, you are right. The router service is not available automatically within an engine.

@dgeb
Copy link
Member

dgeb commented May 18, 2021

@rwjblue @bertdeblock thanks for confirming.

@villander can you please update this PR to remove the lookup deprecation completely? Sorry for all the confusion.

@villander
Copy link
Member Author

villander commented May 19, 2021

Yup @rwjblue @dgeb the service:router is not injected automatically, but many users use router:main to get the router from the host application. It's automatically injected into every engine. Also, we've been using it on #669

Do we want to deprecate the access to router:main into engines or skip it for while? since it's injected on EngineInstance we can deal with that in the next steps?

https://github.com/emberjs/ember.js/blob/21bd70c773dcc4bfe4883d7943e8a68d203b5bad/packages/%40ember/engine/instance.js#L183-L189

@dgeb changes applied, feel free to merge!

Copy link
Member

@dgeb dgeb left a comment

Choose a reason for hiding this comment

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

Thanks @villander - I think this looks good now.

@villander
Copy link
Member Author

Could you please merge it @dgeb? I have no privilege to do it

@rwjblue rwjblue merged commit 1d99f25 into ember-engines:master May 21, 2021
@bertdeblock
Copy link
Contributor

bertdeblock commented May 21, 2021

I think we forgot to update enabled: '0.8.13'. Should be enabled: '0.8.16' now?

@dgeb
Copy link
Member

dgeb commented May 21, 2021

@bertdeblock good call - this is corrected in #774

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

Successfully merging this pull request may close these issues.

None yet

4 participants