Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember.js and arrangedContent

Tags:

ember.js

Can anyone explain to me the purpose of arrangedContent.

The docs explains that it can be overriden in subclasses:

The array that the proxy pretends to be. In the default ArrayProxy implementation, this and content are the same. Subclasses of ArrayProxy can override this property to provide things like sorting and filtering.

What I am confused is its relationship with content. I can see in the source that it has a computed property on the content:

arrangedContent: Ember.computed('content', function(){
  return this.get('content');
}

I think I am in right in saying that you should never bind to the content but instead bind to the arrayProxy itself.

I am assuming that the same holds for arrangedContent?

Do I just use the arrangedContent to filter the array as I need it and bind to the arrayProxy itself or am I missing something?

like image 880
dagda1 Avatar asked Oct 21 '12 13:10

dagda1


1 Answers

You're totally correct: you should always target the proxy itself when binding to values or triggering methods like addObject. Having an arrangedContent allows Ember to manipulate properties of the collection like its sort order or selected item without changing these on the underlying array.

Since a single array of objects can be the underlying data for many parts of an application, you wouldn't necessarily want to change the array itself.

Jame's Croft has a great guide talking about Proxies: http://matchingnotes.com/ember-array-proxy

like image 91
Trek Glowacki Avatar answered Sep 21 '22 17:09

Trek Glowacki