notifySubscribers and equalityComparer are not used outside KnockoutJS

This commit is contained in:
djmaze 2021-12-31 17:10:40 +01:00
parent 679d7356e0
commit 30e9b89d9b
9 changed files with 113 additions and 114 deletions

View file

@ -67,7 +67,7 @@ var ko_subscribable_fn = {
return subscription;
},
"notifySubscribers": function (valueToNotify, event) {
notifySubscribers: function (valueToNotify, event) {
event = event || defaultEvent;
if (event === defaultEvent) {
this.updateVersion();
@ -105,9 +105,9 @@ var ko_subscribable_fn = {
beforeChange = 'beforeChange';
if (!self._origNotifySubscribers) {
self._origNotifySubscribers = self["notifySubscribers"];
self._origNotifySubscribers = self.notifySubscribers;
// Moved out of "limit" to avoid the extra closure
self["notifySubscribers"] = function(value, event) {
self.notifySubscribers = function(value, event) {
if (!event || event === defaultEvent) {
this._limitChange(value);
} else if (event === 'beforeChange') {
@ -165,7 +165,7 @@ var ko_subscribable_fn = {
},
isDifferent: function(oldValue, newValue) {
return !this['equalityComparer'] || !this['equalityComparer'](oldValue, newValue);
return !this.equalityComparer || !this.equalityComparer(oldValue, newValue);
},
toString: () => '[object Object]',
@ -197,4 +197,4 @@ ko.subscribable['fn'] = ko_subscribable_fn;
ko.isSubscribable = instance =>
instance != null && typeof instance.subscribe == "function" && typeof instance["notifySubscribers"] == "function";
instance != null && typeof instance.subscribe == "function" && typeof instance.notifySubscribers == "function";