What's the purpose of ArrayController and ArrayProxy?

帅比萌擦擦* 提交于 2019-12-23 08:46:22

问题


I've been digging into EmberJS for one day :).

I've followed several examples. Some examples used ArrayProxy while others used ArrayController. I looked at the unminified source code and..guess what...Ember.ArrayController is simply extending Ember.ArrayProxy, but there's no extra methods or features in ArrayController.

So..my question is..why do we have two same classes?


回答1:


There is no difference between the two classes.

It's for all of us who are coming from SproutCore 0.9.x, 1.x and early SproutCore 2 betas and were just use to the name ArrayController I think. I'd recommend using ArrayProxy in case the core team decides to depreciate the one line of code that makes ArrayController possible :-)




回答2:


From Ember's API Docs:

Note: As of this writing, ArrayController does not add any functionality to its superclass, ArrayProxy. The Ember team plans to add additional controller-specific functionality in the future, e.g. single or multiple selection support. If you are creating something that is conceptually a controller, use this class.



来源:https://stackoverflow.com/questions/9071570/whats-the-purpose-of-arraycontroller-and-arrayproxy

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