Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
397 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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...)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...