diff --git a/packages/ember-metal/tests/observer_test.js b/packages/ember-metal/tests/observer_test.js index 9af5cc46efa..c1ae204c336 100644 --- a/packages/ember-metal/tests/observer_test.js +++ b/packages/ember-metal/tests/observer_test.js @@ -707,6 +707,7 @@ testBoth('observer should fire before dependent property is modified', function( if (Ember.EXTEND_PROTOTYPES) { testBoth('before observer added declaratively via brace expansion should fire when property changes', function (get, set) { + expectDeprecation(/Function#observesBefore is deprecated and will be removed in the near future/); var obj = {}; var count = 0; @@ -727,6 +728,7 @@ if (Ember.EXTEND_PROTOTYPES) { }); testBoth('before observer specified declaratively via brace expansion should fire when dependent property changes', function (get, set) { + expectDeprecation(/Function#observesBefore is deprecated and will be removed in the near future/); var obj = { baz: 'Initial' }; var count = 0; diff --git a/packages/ember-runtime/lib/ext/function.js b/packages/ember-runtime/lib/ext/function.js index 95921d6922d..442ab73c616 100644 --- a/packages/ember-runtime/lib/ext/function.js +++ b/packages/ember-runtime/lib/ext/function.js @@ -152,6 +152,21 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Function) { */ FunctionPrototype.observesImmediately = Ember.deprecateFunc('Function#observesImmediately is deprecated. Use Function#observes instead', FunctionPrototype._observesImmediately); + + FunctionPrototype._observesBefore = function () { + var watched = []; + var addWatchedProperty = function (obs) { + watched.push(obs); + }; + + for (var i = 0, l = arguments.length; i < l; ++i) { + expandProperties(arguments[i], addWatchedProperty); + } + + this.__ember_observesBefore__ = watched; + + return this; + }; /** The `observesBefore` extension of Javascript's Function prototype is available when `Ember.EXTEND_PROTOTYPES` or @@ -175,20 +190,7 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Function) { @for Function @private */ - FunctionPrototype.observesBefore = function () { - var watched = []; - var addWatchedProperty = function (obs) { - watched.push(obs); - }; - - for (var i = 0, l = arguments.length; i < l; ++i) { - expandProperties(arguments[i], addWatchedProperty); - } - - this.__ember_observesBefore__ = watched; - - return this; - }; + FunctionPrototype.observesBefore = Ember.deprecateFunc('Function#observesBefore is deprecated and will be removed in the near future.', { url: 'http://emberjs.com/deprecations/v1.x/#toc_beforeobserver' }, FunctionPrototype._observesBefore); /** The `on` extension of Javascript's Function prototype is available