Comments (7)
@LucasHillDex shouldn't this.router.transitionTo()
just work? this.hostRouter.transitionTo()
per https://ember-engines.com/docs/deprecations#-use-alias-for-inject-router-service-from-host-application yes would do transition in the context of the host app.
from ember-engines.
@LucasHillDex shouldn't
this.router.transitionTo()
just work?this.hostRouter.transitionTo()
per https://ember-engines.com/docs/deprecations#-use-alias-for-inject-router-service-from-host-application yes would do transition in the context of the host app.
@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 this.transitionTo('comments')
. Post 5.0 given those APIs are gone, if we use the host's router, we'd have to call something like this.router.transitionTo('home.engine.comments')
, but what if in another app the engine is mounted under a completely different parent route or mount name?
from ember-engines.
@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?
from ember-engines.
@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
from ember-engines.
@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.
from ember-engines.
@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 ended up finding my own workaround but that addon looks useful (hate to add another addon though that might not get updates in the future). I think it would be good for the engines team to really look into the routing issues and either document it better if solutions exist or explore improving the API.
from ember-engines.
Hello @LucasHillDex
we're working tightly with the ember routing work to make sure engines are better supported going forward out of the box
would love to know what workaround you found for the issue you were having
for now the recommendation is to use the addon routing service for engines until a transition path is built towards new routing
from ember-engines.
Related Issues (20)
- getOwner doesn't return the context for the route HOT 3
- cannot find module "@ember/routing/link-component" in ember ~4.1 HOT 3
- Class extends value [object Object] is not a constructor or null HOT 4
- Could not find module `@ember/legacy-built-in-components` HOT 2
- error reading "inaccessibleByURL" is undefined sometimes
- build error after upgrading to 0.9.0 HOT 3
- Service dependencies do not pass through properly in embedded engine (Ember 3.28) HOT 3
- Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'on') HOT 1
- dependencies do not pass through properly in embedded engine under single spa
- 0.8.22 breaks compatability with Ember > 3.24 HOT 2
- Transitioning from one engine route to another triggers a Cannot read properties of undefined (reading 'shouldSupersede')
- Rebuild crash on Ember 4.12.1 apps - Ember CSS file HOT 1
- Getting ember-source dependency conflict with ember-source 5.3 HOT 10
- TypeScript compiling not working without ember-cli-typescript in Ember 5 HOT 5
- Memory leak in tests when using setupEngine helper HOT 2
- Test teardown sequencing issue with the setupEngine helper. HOT 2
- How to write unit tests for utilities? HOT 2
- Provide a test helper that wraps render()? HOT 3
- Addon Services local to engines not able to be injected HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-engines.