Skip to content

Commit

Permalink
Merge pull request #15895 from bekzod/cleanup-assert
Browse files Browse the repository at this point in the history
[CLEANUP beta] convert error to assertion
  • Loading branch information
rwjblue authored Nov 30, 2017
2 parents f1850bc + d06008a commit 62761c5
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions packages/ember-metal/lib/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import {
import {
debugSeal,
assert,
deprecate,
EmberError
deprecate
} from 'ember-debug';
import { DEBUG } from 'ember-env-flags';
import { meta as metaFor, peekMeta } from './meta';
Expand Down Expand Up @@ -843,29 +842,22 @@ export function _immediateObserver() {
*/
export function _beforeObserver(...args) {
let func = args[args.length - 1];
let paths;

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

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

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

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

paths = [];
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);
}

if (typeof func !== 'function') {
throw new EmberError('_beforeObserver called without a function');
}

func.__ember_observesBefore__ = paths;
return func;
}
Expand Down

0 comments on commit 62761c5

Please sign in to comment.