Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLEANUP] removed providing reversed arguments to observer #15893

Merged
merged 1 commit into from
Dec 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions packages/ember-metal/lib/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,17 +757,8 @@ export function aliasMethod(methodName) {
@static
*/
export function observer(...args) {
let _paths, func;
if (typeof args[args.length - 1] !== 'function') {
// revert to old, soft-deprecated argument ordering
deprecate('Passing the dependentKeys after the callback function in observer is deprecated. Ensure the callback function is the last argument.', false, { id: 'ember-metal.observer-argument-order', until: '3.0.0' });

func = args.shift();
_paths = args;
} else {
func = args.pop();
_paths = args;
}
let func = args.pop();
let _paths = args;

assert('observer called without a function', typeof func === 'function');
assert('observer called without valid path', _paths.length > 0 && _paths.every((p)=> typeof p === 'string' && p.length));
Expand Down Expand Up @@ -841,19 +832,14 @@ export function _immediateObserver() {
@private
*/
export function _beforeObserver(...args) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed providing reversed arguments to _beforeObserver too

let func = args[args.length - 1];

let _paths = args.slice(0, -1);
if (typeof func !== 'function') {
// revert to old, soft-deprecated argument ordering
func = args[0];
_paths = args.slice(1);
}
let func = args.pop();
let _paths = args;

assert('_beforeObserver called without a function', typeof func === 'function');

let paths = [];
let addWatchedProperty = path => { paths.push(path); };

for (let i = 0; i < _paths.length; ++i) {
expandProperties(_paths[i], addWatchedProperty);
}
Expand Down
11 changes: 0 additions & 11 deletions packages/ember-metal/tests/mixin/observer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,3 @@ testBoth('observing chain with overridden property', function(get, set) {
set(obj3, 'baz', 'BEAR');
equal(get(obj, 'count'), 1, 'should invoke observer after change');
});

testBoth('providing the arguments in reverse order is deprecated', function(get, set) {
expectDeprecation(/Passing the dependentKeys after the callback function in observer is deprecated. Ensure the callback function is the last argument/);

Mixin.create({
count: 0,
foo: observer(function() {
set(this, 'count', get(this, 'count') + 1);
}, 'bar.baz')
});
});
2 changes: 0 additions & 2 deletions packages/ember-metal/tests/observer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ testBoth('observer should assert to invalid input', function(get, set) {
observer(()=>{});
}, 'observer called without valid path');

expectDeprecation('Passing the dependentKeys after the callback function in observer is deprecated. Ensure the callback function is the last argument.');

expectAssertion(()=> {
observer(null);
}, 'observer called without a function');
Expand Down