mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 05:59:21 +03:00
Remove more unused Knockout code
This commit is contained in:
parent
07857a06a9
commit
ac535b1d03
14 changed files with 155 additions and 355 deletions
|
|
@ -76,10 +76,6 @@ ko.computed = ko.dependentObservable = function (evaluatorFunctionOrOptions, eva
|
|||
ko.utils.extend(computedObservable, deferEvaluationOverrides);
|
||||
}
|
||||
|
||||
if (ko.options['deferUpdates']) {
|
||||
ko.extenders['deferred'](computedObservable, true);
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
// #1731 - Aid debugging by exposing the computed's options
|
||||
computedObservable["_options"] = options;
|
||||
|
|
@ -210,19 +206,7 @@ var computedFn = {
|
|||
}
|
||||
},
|
||||
subscribeToDependency: function (target) {
|
||||
if (target._deferUpdates) {
|
||||
var dirtySub = target.subscribe(this.markDirty, this, 'dirty'),
|
||||
changeSub = target.subscribe(this.respondToChange, this);
|
||||
return {
|
||||
_target: target,
|
||||
dispose: () => {
|
||||
dirtySub.dispose();
|
||||
changeSub.dispose();
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return target.subscribe(this.evaluatePossiblyAsync, this);
|
||||
}
|
||||
return target.subscribe(this.evaluatePossiblyAsync, this);
|
||||
},
|
||||
evaluatePossiblyAsync: function () {
|
||||
var computedObservable = this,
|
||||
|
|
|
|||
30
vendors/knockout/src/subscribables/extenders.js
vendored
30
vendors/knockout/src/subscribables/extenders.js
vendored
|
|
@ -28,40 +28,10 @@ ko.extenders = {
|
|||
method = options['method'];
|
||||
}
|
||||
|
||||
// rateLimit supersedes deferred updates
|
||||
target._deferUpdates = false;
|
||||
|
||||
limitFunction = typeof method == 'function' ? method : method == 'notifyWhenChangesStop' ? debounce : throttle;
|
||||
target.limit(callback => limitFunction(callback, timeout, options));
|
||||
},
|
||||
|
||||
'deferred': (target, options) => {
|
||||
if (options !== true) {
|
||||
throw new Error('The \'deferred\' extender only accepts the value \'true\', because it is not supported to turn deferral off once enabled.')
|
||||
}
|
||||
|
||||
if (!target._deferUpdates) {
|
||||
target._deferUpdates = true;
|
||||
target.limit(callback => {
|
||||
var handle,
|
||||
ignoreUpdates = false;
|
||||
return () => {
|
||||
if (!ignoreUpdates) {
|
||||
ko.tasks.cancel(handle);
|
||||
handle = ko.tasks.schedule(callback);
|
||||
|
||||
try {
|
||||
ignoreUpdates = true;
|
||||
target['notifySubscribers'](undefined, 'dirty');
|
||||
} finally {
|
||||
ignoreUpdates = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
'notify': (target, notifyWhen) => {
|
||||
target["equalityComparer"] = notifyWhen == "always" ?
|
||||
null : // null equalityComparer means to always notify
|
||||
|
|
|
|||
|
|
@ -32,10 +32,6 @@ ko.observable = initialValue => {
|
|||
// Inherit from 'observable'
|
||||
ko.utils.setPrototypeOfOrExtend(observable, observableFn);
|
||||
|
||||
if (ko.options['deferUpdates']) {
|
||||
ko.extenders['deferred'](observable, true);
|
||||
}
|
||||
|
||||
return observable;
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +72,6 @@ ko.isWriteableObservable = instance => {
|
|||
ko.exportSymbol('observable', ko.observable);
|
||||
ko.exportSymbol('isObservable', ko.isObservable);
|
||||
ko.exportSymbol('isWriteableObservable', ko.isWriteableObservable);
|
||||
ko.exportSymbol('isWritableObservable', ko.isWriteableObservable);
|
||||
ko.exportSymbol('observable.fn', observableFn);
|
||||
ko.exportProperty(observableFn, 'peek', observableFn.peek);
|
||||
ko.exportProperty(observableFn, 'valueHasMutated', observableFn.valueHasMutated);
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ if (ko.utils.canSetPrototype) {
|
|||
// Populate ko.observableArray.fn with read/write functions from native arrays
|
||||
// Important: Do not add any additional functions here that may reasonably be used to *read* data from the array
|
||||
// because we'll eval them without causing subscriptions, so ko.computed output could end up getting stale
|
||||
ko.utils.arrayForEach(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], methodName => {
|
||||
["pop", "push", "reverse", "shift", "sort", "splice", "unshift"].forEach(methodName => {
|
||||
ko.observableArray['fn'][methodName] = function () {
|
||||
// Use "peek" to avoid creating a subscription in any computed that we're executing in the context of
|
||||
// (for consistency with mutating regular observables)
|
||||
|
|
@ -81,7 +81,7 @@ ko.utils.arrayForEach(["pop", "push", "reverse", "shift", "sort", "splice", "uns
|
|||
});
|
||||
|
||||
// Populate ko.observableArray.fn with read-only functions from native arrays
|
||||
ko.utils.arrayForEach(["slice"], methodName => {
|
||||
["slice"].forEach(methodName => {
|
||||
ko.observableArray['fn'][methodName] = function () {
|
||||
var underlyingArray = this();
|
||||
return underlyingArray[methodName].apply(underlyingArray, arguments);
|
||||
|
|
|
|||
|
|
@ -166,10 +166,9 @@ var ko_subscribable_fn = {
|
|||
return this._subscriptions[event] && this._subscriptions[event].length || 0;
|
||||
}
|
||||
var total = 0;
|
||||
ko.utils.objectForEach(this._subscriptions, (eventName, subscriptions) => {
|
||||
if (eventName !== 'dirty')
|
||||
total += subscriptions.length;
|
||||
});
|
||||
ko.utils.objectForEach(this._subscriptions, (eventName, subscriptions) =>
|
||||
total += subscriptions.length
|
||||
);
|
||||
return total;
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue