Skip to content

Commit

Permalink
Merge pull request #11464 from thejameskyle/tjk/deprecate-immediate-o…
Browse files Browse the repository at this point in the history
…bserver

Deprecate immediateObserver
  • Loading branch information
stefanpenner committed Jun 15, 2015
2 parents 0336d40 + ad080da commit 8115fbc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/ember-metal/lib/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -793,9 +793,6 @@ export function aliasMethod(methodName) {
});
```
In the future this method may become asynchronous. If you want to ensure
synchronous behavior, use `immediateObserver`.
Also available as `Function.prototype.observes` if prototype extensions are
enabled.
Expand Down Expand Up @@ -855,10 +852,13 @@ export function observer(...args) {
@for Ember
@param {String} propertyNames*
@param {Function} func
@deprecated Use `Ember.observer` instead.
@return func
@private
*/
export function immediateObserver() {
Ember.deprecate('Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead.');

for (var i=0, l=arguments.length; i<l; i++) {
var arg = arguments[i];
Ember.assert("Immediate observers must observe internal properties only, not properties on other objects.",
Expand Down
5 changes: 4 additions & 1 deletion packages/ember-metal/tests/observer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1051,9 +1051,10 @@ testBoth('setting a cached computed property whose value has changed should trig
equal(get(obj, 'foo'), 'bar');
});

QUnit.module("Ember.immediateObserver");
QUnit.module("Ember.immediateObserver (Deprecated)");

testBoth("immediate observers should fire synchronously", function(get, set) {
expectDeprecation(/Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead./);
var obj = {};
var observerCalled = 0;
var mixin;
Expand Down Expand Up @@ -1119,6 +1120,7 @@ if (Ember.EXTEND_PROTOTYPES) {
}

testBoth('immediate observers watching multiple properties via brace expansion fire synchronously', function (get, set) {
expectDeprecation(/Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead./);
var obj = {};
var observerCalled = 0;
var mixin;
Expand Down Expand Up @@ -1150,6 +1152,7 @@ testBoth('immediate observers watching multiple properties via brace expansion f
});

testBoth("immediate observers are for internal properties only", function(get, set) {
expectDeprecation(/Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead./);
expectAssertion(function() {
immediateObserver('foo.bar', function() { return this; });
}, 'Immediate observers must observe internal properties only, not properties on other objects.');
Expand Down

0 comments on commit 8115fbc

Please sign in to comment.