-
Notifications
You must be signed in to change notification settings - Fork 138
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
Internal engine routing problems on Ember 5.x #856
Comments
@LucasHillDex shouldn't |
@SergeAstapov Being that this is the host router you would need to provide the entire qualified route, including any part of the host app's parent route to the mounted engine. This breaks the encapsulation of the engine, and wouldn't work in one app where the engine is mounted in a different path than in another. Imagine I have two engine routes called 'posts' and 'comments'. In ember 4.x and below, we could be in the 'posts' engine route and call |
@SergeAstapov I came up with a minimal example to demonstrate the issue we're having: https://github.com/LucasHillDex/engine-routing This is a simple routable engine addon. It has two routes, "first" and "second". In the beforeModel hook of "first" we want to transition to "second". I have illustrated the way would would use the old APIs to transition from one engine route into another. This does not seem possible now without knowing the structure of the host/parent app of the engine if you are using the inject host's router service. See: https://github.com/LucasHillDex/engine-routing/blob/main/addon/routes/first.js I don't think this is an unusual use case or is it? Is there another supported way to do internal engine routing? |
@SergeAstapov I don't think I addressed your response properly, ember-engines does not allow you to inject the plain 'router' service anymore, as I believe that was still just the host's router (is that wrong?). Which is why it was made that you had to explicitly do it like: https://ember-engines.com/docs/deprecations#-use-alias-for-inject-router-service-from-host-application See the example here for what happens when you try to just use the plain router service in an engine route. https://github.com/LucasHillDex/engine-routing/blob/main/addon/routes/first.js#L5 |
@LucasHillDex have you seen https://github.com/villander/ember-engines-router-service? This addon preserves the encapsulation you're looking for when routing via service within an engine. |
I'm having an issue due to the removal of route+controller transition methods in Ember > 5 (this.transitionTo etc). With those methods now unavailable, when we transition between engine routes inside of the engine, I'm not sure what API is available. The "engine router service" appears to have stalled out? Is there another way? #779
If you inject the host router via https://ember-engines.com/docs/deprecations#-use-alias-for-inject-router-service-from-host-application it is routing in the context of the host app not the engine and won't work for transitioning purely within the engine routes.
The text was updated successfully, but these errors were encountered: