Is application state in Ember too much coupled to the URL?

Does Ember support a paradigm like the UINavigationController in Cocoa? It would be great if there was some way to use view controllers to create complex view hierarchies that don’t match the URL one-to-one. Like navigation controllers inside tab controllers for example.

It seems Ember currently relies on a lot of singleton controllers and the router doesn’t really support anything like a controller that manages a ‘controller hierarchy’.

Perhaps I’m just not familiar enough with Ember and it’s inner workings, and it does support something like this?

2 Likes

I actually have the same question. It would be pretty useful if a controller can manage a controller hierarchy. It is really common that a component would have its own logic which should be put into its own controller, and there is a parent controller that manages this controller. I feel I have to “bend” the framework every time when I want to share some complex component.

Maybe I just do not know the ember way of doing this properly?

There’s an important distinction between a Cocoa view hierarchy and the way Ember does things: in Ember, every state needs to map to a URL, and needs to play nice with the browser’s own navigation.

So in an Ember application, you essentially always have a UINavigationController managing a stack of states for you – the browser itself!

We can use the router DSL to succinctly define arbitrarily nested hierarchies of view controllers, and the browser takes care of letting the user navigate forward and backward through them.

This is actually a critical point. The whole reason Ember exists is to embrace the nature of the web instead of trying to fight it. That’s why Ember forked off from Sproutcore, which tries to hide the web and make it look like native application development.

1 Like

Hey @Rengers, does https://github.com/emberjs/ember.js/pull/3424 help?

What you’re actually accessing are routes and resources, which have an optional path for the URL. For example, you may have this.route(“login”, { path: ‘/sign-out’}) that would log you in regardless of what the URL is telling you.

What you actually want to look into if you want modals/popups and you dont want to switch routes, then you can either use a nested outlet or render a view in place. Use {{render}} or an {{outlet}} and manage state from within your controller.