Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 0554c1a

Browse files
IgorMinarrodyhaddad
authored andcommitted
chore(Scope): remove deregisterNotifier feature for $watch
We no longer have a need for this feature that was added to primarily support $watchGroup (see previous commit). BREAKING CHANGE: deregisterNotifier callback for $watch is no longer available This api was available only in the last few 1.3 beta versions and is not very useful for applications, so we don't expect that anyone will be affected by this change.
1 parent 3f0e642 commit 0554c1a

File tree

4 files changed

+9
-42
lines changed

4 files changed

+9
-42
lines changed

src/ng/interpolate.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,15 @@ function $InterpolateProvider() {
301301
exp: text, //just for compatibility with regular watchers created via $watch
302302
separators: separators,
303303
expressions: expressions,
304-
$$watchDelegate: function (scope, listener, objectEquality, deregisterNotifier) {
304+
$$watchDelegate: function (scope, listener, objectEquality) {
305305
var lastValue;
306306
return scope.$watchGroup(parseFns, function interpolateFnWatcher(values, oldValues) {
307307
var currValue = compute(values);
308308
if (isFunction(listener)) {
309309
listener.call(this, currValue, values !== oldValues ? lastValue : currValue, scope);
310310
}
311311
lastValue = currValue;
312-
}, objectEquality, deregisterNotifier);
312+
}, objectEquality);
313313
}
314314
});
315315
}

src/ng/parse.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ function $ParseProvider() {
10351035
}
10361036
};
10371037

1038-
function oneTimeWatch(scope, listener, objectEquality, deregisterNotifier, parsedExpression) {
1038+
function oneTimeWatch(scope, listener, objectEquality, parsedExpression) {
10391039
var unwatch, lastValue;
10401040
return unwatch = scope.$watch(function oneTimeWatch(scope) {
10411041
return parsedExpression(scope);
@@ -1051,10 +1051,10 @@ function $ParseProvider() {
10511051
}
10521052
});
10531053
}
1054-
}, objectEquality, deregisterNotifier);
1054+
}, objectEquality);
10551055
}
10561056

1057-
function oneTimeLiteralWatch(scope, listener, objectEquality, deregisterNotifier, parsedExpression) {
1057+
function oneTimeLiteralWatch(scope, listener, objectEquality, parsedExpression) {
10581058
var unwatch;
10591059
return unwatch = scope.$watch(function oneTimeWatch(scope) {
10601060
return parsedExpression(scope);
@@ -1078,7 +1078,7 @@ function $ParseProvider() {
10781078
}
10791079
}
10801080

1081-
function constantWatch(scope, listener, objectEquality, deregisterNotifier, parsedExpression) {
1081+
function constantWatch(scope, listener, objectEquality, parsedExpression) {
10821082
var unwatch;
10831083
return unwatch = scope.$watch(function constantWatch(scope) {
10841084
return parsedExpression(scope);
@@ -1087,7 +1087,7 @@ function $ParseProvider() {
10871087
listener.apply(this, arguments);
10881088
}
10891089
unwatch();
1090-
}, objectEquality, deregisterNotifier);
1090+
}, objectEquality);
10911091
}
10921092

10931093
function addInterceptor(parsedExpression, interceptorFn) {

src/ng/rootScope.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -322,15 +322,13 @@ function $RootScopeProvider(){
322322
* - `scope` refers to the current scope
323323
* @param {boolean=} objectEquality Compare for object equality using {@link angular.equals} instead of
324324
* comparing for reference equality.
325-
* @param {function()=} deregisterNotifier Function to call when the deregistration function
326-
* get called.
327325
* @returns {function()} Returns a deregistration function for this listener.
328326
*/
329-
$watch: function(watchExp, listener, objectEquality, deregisterNotifier) {
327+
$watch: function(watchExp, listener, objectEquality) {
330328
var get = compileToFn(watchExp, 'watch');
331329

332330
if (get.$$watchDelegate) {
333-
return get.$$watchDelegate(this, listener, objectEquality, deregisterNotifier, get);
331+
return get.$$watchDelegate(this, listener, objectEquality, get);
334332
}
335333
var scope = this,
336334
array = scope.$$watchers,
@@ -358,9 +356,6 @@ function $RootScopeProvider(){
358356
return function deregisterWatch() {
359357
arrayRemove(array, watcher);
360358
lastDirtyWatch = null;
361-
if (isFunction(deregisterNotifier)) {
362-
deregisterNotifier();
363-
}
364359
};
365360
},
366361

test/ng/rootScopeSpec.js

-28
Original file line numberDiff line numberDiff line change
@@ -526,34 +526,6 @@ describe('Scope', function() {
526526
expect(log).toEqual(['watch1', 'watchAction1', 'watch2', 'watchAction2', 'watch3', 'watchAction3',
527527
'watch2', 'watch3']);
528528
}));
529-
530-
describe('deregisterNotifier', function () {
531-
it('should call the deregisterNotifier when the watch is deregistered', inject(
532-
function($rootScope) {
533-
var notifier = jasmine.createSpy('deregisterNotifier');
534-
var listenerRemove = $rootScope.$watch('noop', noop, false, notifier);
535-
536-
expect(notifier).not.toHaveBeenCalled();
537-
538-
listenerRemove();
539-
expect(notifier).toHaveBeenCalledOnce();
540-
}));
541-
542-
543-
it('should call the deregisterNotifier when a one-time expression is stable', inject(
544-
function($rootScope) {
545-
var notifier = jasmine.createSpy('deregisterNotifier');
546-
$rootScope.$watch('::foo', noop, false, notifier);
547-
548-
expect(notifier).not.toHaveBeenCalledOnce();
549-
$rootScope.$digest();
550-
expect(notifier).not.toHaveBeenCalledOnce();
551-
552-
$rootScope.foo = 'foo';
553-
$rootScope.$digest();
554-
expect(notifier).toHaveBeenCalledOnce();
555-
}));
556-
});
557529
});
558530

559531

0 commit comments

Comments
 (0)