Live data from Hacker News

EmberJS Confuses Me

wekeroad.com

1–10 of 142 posts

Re: EmberJS Confuses Me

#2
Well, I don't know EmberJS but for the handlebars code you showed, seems like the controller is somewhat more like a ViewModel (MVVM pattern), maybe learning KnockoutJS first would help a bit?

Re: EmberJS Confuses Me

#3
post #2

Well, I don't know EmberJS but for the handlebars code you showed, seems like the controller is somewhat more like a ViewModel (MVVM pattern), maybe learning KnockoutJS first would help a bit?

Rob has done knockout, and that's pretty unrelated I feel. I've spent a lot of time doing Knockout and a fair amount of time in Angular and Backbone, and personally I sort of agree with what rob is saying. I feel like they have taken MVC and just loosely applied it in Ember, because they have Models Views and Controllers. I see and understand where his confusion is coming from. I probably also haven't spent enough time with Ember to get it, but I also don't feel like I want to.

Re: EmberJS Confuses Me

#4
> The downside to this approach is that your HTML is "compromised", if you will, and many developers don't like that. My thought is that it's already compromised using Handlebars so what's the difference here? Personally I have no issue using the ng-* directives. Some people do, and I respect that.

I'm a bit off-topic, but you don't need to "compromise" your HTML with AngularJS, you can place "data-" in front of your attributes and you're HTML-compliant again :).

Re: EmberJS Confuses Me

#5
The examples provided to describe the difference between controllers in Ember and Angular do not appear to be different to me at all. In fact I'd argue that they are identical. It feels to me as though the author is wanting them to be different because maybe it's a style preference from the templating perspective?

Re: EmberJS Confuses Me

#6
Really nice constructive writeup (as always by Rob), and I think it should be addressed by some better EmberJS docs and tutorials. They do a good job explaining the "what", but it could probably use more "why".

It took me a while as well to figure out why controllers proxied to models. However it started to make a lot of sense in when building an app, since the controllers are there to stay around, and the models are swappable.

Having the option to easily swap out a model at the controller level is worth the extra layer abstraction. That and the ability to add additional UI specific properties on the controller that don't necessarily belong in the model (since they don't need to be persisted).

Re: EmberJS Confuses Me

#8

> The downside to this approach is that your HTML is "compromised", if you will, and many developers don't like that. My thought is that it's already compromised using Handlebars so what's the difference here? Personally I have no issue using the ng-* directives. Some people do, and I respect that. I'm a bit off-topic, but you don't need to "compromise" your HTML with AngularJS, you can place "data-" in front of your…

Absolutely true - I should add that in. I think people look at that, however, and don't like functionality etc. shoved into the DOM. But your point stands.

Re: EmberJS Confuses Me

#9
I've never used EmberJS and am not familiar with any of the front-end JavaScript frameworks, but I don't get what's confusing.

It looks like instead of the controller pushing data to the view, the view asks the controller for data (which it might proxy to the model).

This makes sense with a long-running controller, right? On the web both the controller and view are ephemeral -- they last for just that one request -- but if the controller is running continuously then it needs to reflect changes in the models as they happen. The model(s) the controller references can change without the view changing its reference to the controller.

Without something like this the view would render stale data. I'm assuming this is why we have a controller.model, to add that layer of indirection.

What am I missing? How is this more complicated making the controllerview relationship pull instead of push?

Re: EmberJS Confuses Me

#10

The examples provided to describe the difference between controllers in Ember and Angular do not appear to be different to me at all. In fact I'd argue that they are identical. It feels to me as though the author is wanting them to be different because maybe it's a style preference from the templating perspective?

The examples were to show how $scope is used in Angular vs direct use of the Controller/Model proxy in Ember. This makes a bit more sense to me, personally.
Post reply on HN