问题
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