EmberJS: Good separation of concerns for Models, Stores, Controllers, Views in a rather complex application?

懵懂的女人 提交于 2019-11-30 08:59:54
  • You should think of your application in terms of states. Have a look at this

  • Initially, only a route and a template are required to describe something and finally display it in the browser, that's what the new API of Emberjs tries to enforce. As your requirements get more elaborate you can throw in a view, a controller or an object. Each though answers a specific need.

  • Consider a view if you need to handle any browser events or wrap
    any 3rd party javascript lib you're using for animation, styling ..

  • Consider an Object if you need to capture domain specific
    information, most likely mimics backend information.

  • A controller is merely a proxy for the domain object and may encapsulate logic that doesn't pertain necessarily to the object.

That's all what's to it. If you learn how to design your application in terms of states, the rest will fall into the right place, providing you're using the latest api, enforcing the rules i mentioned previously.

Since the release of Ember 1.0.0-pre4 with the new router implementation I've seen two good references describing a standardised EmberJS app structure.

Those of you familiar with Rails would find it fairly familiar.

https://github.com/trek/ember-todos-with-build-tools-tests-and-other-modern-conveniences

http://reefpoints.dockyard.com/ember/2013/01/07/building-an-ember-app-with-rails-api-part-1.html

The ember-rails project at https://github.com/emberjs/ember-rails includes a Rails generator for creating an EmberJS application directory structure that is essentially the same as the structure described in the two links above.

The EmberJS guides also now describe the new routing structure. http://emberjs.com/guides/

UPDATE 21/08/2013

If you are using Rails then the ember-rails gem is great. I've used it with a lot of success. There are two efforts within the ember community to assist in providing a standardised ember application layout. Apparently they are going to be merged but for now check out:

https://github.com/rpflorence/ember-tools

https://github.com/stefanpenner/ember-app-kit

See also this http://addyosmani.com/largescalejavascript/ It is not about EmberJs in particular but it's a great article that gives you an idea how to write larg scale javascript apps.

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