Emberjs develop a component in isolation with its own routing/states, which can be integrated to main app

社会主义新天地 提交于 2019-11-27 03:40:39

问题


I need to develop a component in ember.

The component logic is somewhat isolated from main application and can be created as a seperate isolated application, with states and routes within the component.

Presently I have root controller of component as 'ApplicationController' to enable routing, the name 'applicationController' looks like hard coded.

Now I have the main application with its 'ApplicationController' + related routing, and my component with its 'ApplicationController' + related routing. It looks hard to integrate them.

Is there any way to have multiple components like this seperated my namespaces? See comments here

So the main concern is a method to develop an ember component with routin/states in isolation, that is easy to integrate back with main application which also has routing/states.

EDIT

I have two values in component that is bound to main application that is the only integration. Also component routes must come as part of application route once integrated.

Eg: #/approuteforcomponent/componentroute/componentroute2/

While developing I should be able to do just

#/approuteforcomponent  -- shows a page saying component under construction
#/componentroute/componentroute2/

That being said, the main issue I have now is about both main application and component using 'ApplicationControler

UPDATE

Similar Question

Does ember.js encourage too many controllers?


回答1:


What is the degree of integration you wish to achieve, back with main application? I mean: is the wanted isolation only related to code structure? or aims to factorized components reuse?

Are main app & component routing really unrelated?

You have at least two possible approaches:

  • You could setup several ember applications, with possible weak relations between them, but the routing relies on browser's base state, so it does not sounds like it makes sense to have several routers instanciated simultaneously with concurrent location management...

  • You also could develop your app with an addons architecture, having addons reopening the main app's routes, and stronger relations between app & addons (that's what we are doing here where I am working...)



来源:https://stackoverflow.com/questions/11391333/emberjs-develop-a-component-in-isolation-with-its-own-routing-states-which-can

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!