beforeObserver (propertyNames, func) deprecatedprivate
When observers fire, they are called with the arguments obj
, keyName
.
Note, @each.property
observer is called per each add or replace of an element and it's not called with a specific enumeration item.
A _beforeObserver
fires before a property changes.
A _beforeObserver
is an alternative form of .observesBefore()
.
App.PersonView = Ember.View.extend({ friends: [{ name: 'Tom' }, { name: 'Stefan' }, { name: 'Kris' }], valueDidChange: Ember.observer('content.value', function(obj, keyName) { // only run if updating a value already in the DOM if (this.get('state') === 'inDOM') { let color = obj.get(keyName) > this.changingFrom ? 'green' : 'red'; // logic } }), friendsDidChange: Ember.observer('friends.@each.name', function(obj, keyName) { // some logic // obj.get(keyName) returns friends array }) });
Also available as Function.prototype.observesBefore
if prototype extensions are enabled.
Parameters:
-
propertyNames
String
-
func
Function
Returns:
- func
Please login to continue.