benchmarks/scenarios/ember.js
function _beforeObserver() {
    for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
      args[_key5] = arguments[_key5];
    }

    var func = args.slice(-1)[0];
    var paths;

    var addWatchedProperty = function (path) {
      paths.push(path);
    };

    var _paths = args.slice(0, -1);

    if (typeof func !== 'function') {
      // revert to old, soft-deprecated argument ordering

      func = args[0];
      _paths = args.slice(1);
    }

    paths = [];

    for (var i = 0; i < _paths.length; ++i) {
      _emberMetalExpand_properties.default(_paths[i], addWatchedProperty);
    }

    if (typeof func !== 'function') {
      throw new _emberMetalCore.default.Error('Ember.beforeObserver called without a function');
    }

    func.__ember_observesBefore__ = paths;
    return func;
  }
function _beforeObserver() {
    for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
      args[_key5] = arguments[_key5];
    }

    var func = args.slice(-1)[0];
    var paths;

    var addWatchedProperty = function (path) {
      paths.push(path);
    };

    var _paths = args.slice(0, -1);

    if (typeof func !== 'function') {
      // revert to old, soft-deprecated argument ordering

      func = args[0];
      _paths = args.slice(1);
    }

    paths = [];

    for (var i = 0; i < _paths.length; ++i) {
      _emberMetalExpand_properties.default(_paths[i], addWatchedProperty);
    }

    if (typeof func !== 'function') {
      throw new _emberMetalCore.default.Error('Ember.beforeObserver called without a function');
    }

    func.__ember_observesBefore__ = paths;
    return func;
  }
function _beforeObserver ( ) { for ( var _len5 = arguments . length , args = Array ( _len5 ) , _key5 = 0 ; _key5 < _len5 ; _key5 ++ ) { args [ _key5 ] = arguments [ _key5 ] ; } var func = args . slice ( - 1 ) [ 0 ] ; var paths ; var addWatchedProperty = function ( path ) { paths . push ( path ) ; } ; var _paths = args . slice ( 0 , - 1 ) ; if ( typeof func !== 'function' ) { // revert to old, soft-deprecated argument ordering func = args [ 0 ] ; _paths = args . slice ( 1 ) ; } paths = [ ] ; for ( var i = 0 ; i < _paths . length ; ++ i ) { _emberMetalExpand_properties . default ( _paths [ i ] , addWatchedProperty ) ; } if ( typeof func !== 'function' ) { throw new _emberMetalCore . default . Error ( 'Ember.beforeObserver called without a function' ) ; } func . __ember_observesBefore__ = paths ; return func ; }
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()`.

```javascript
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') {
var 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.

@method beforeObserver
@for Ember
@param {String} propertyNames*
@param {Function} func
@return func
@deprecated
@private
When observers fire they are called with the arguments obj keyName .