mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 05:59:21 +03:00
Drop unused Knockout functionality
Especially dropped memoization for improved speed.
This commit is contained in:
parent
e7975d4f82
commit
1e735bf4a9
30 changed files with 206 additions and 814 deletions
|
|
@ -56,11 +56,3 @@ ko.computedContext = ko.dependencyDetection = (() => {
|
|||
}
|
||||
};
|
||||
})();
|
||||
|
||||
ko.exportSymbol('computedContext', ko.computedContext);
|
||||
ko.exportSymbol('computedContext.getDependenciesCount', ko.computedContext.getDependenciesCount);
|
||||
ko.exportSymbol('computedContext.getDependencies', ko.computedContext.getDependencies);
|
||||
ko.exportSymbol('computedContext.isInitial', ko.computedContext.isInitial);
|
||||
ko.exportSymbol('computedContext.registerDependency', ko.computedContext.registerDependency);
|
||||
|
||||
ko.exportSymbol('ignoreDependencies', ko.ignoreDependencies = ko.dependencyDetection.ignore);
|
||||
|
|
|
|||
|
|
@ -493,19 +493,9 @@ if (ko.utils.canSetPrototype) {
|
|||
var protoProp = ko.observable.protoProperty; // == "__ko_proto__"
|
||||
computedFn[protoProp] = ko.computed;
|
||||
|
||||
ko.isComputed = instance => (typeof instance == 'function' && instance[protoProp] === computedFn[protoProp]);
|
||||
|
||||
ko.isPureComputed = instance => ko.isComputed(instance) && instance[computedState] && instance[computedState].pure;
|
||||
|
||||
ko.exportSymbol('computed', ko.computed);
|
||||
ko.exportSymbol('isComputed', ko.isComputed);
|
||||
ko.exportSymbol('isPureComputed', ko.isPureComputed);
|
||||
ko.exportSymbol('computed.fn', computedFn);
|
||||
ko.exportProperty(computedFn, 'peek', computedFn.peek);
|
||||
ko.exportProperty(computedFn, 'dispose', computedFn.dispose);
|
||||
ko.exportProperty(computedFn, 'isActive', computedFn.isActive);
|
||||
ko.exportProperty(computedFn, 'getDependenciesCount', computedFn.getDependenciesCount);
|
||||
ko.exportProperty(computedFn, 'getDependencies', computedFn.getDependencies);
|
||||
|
||||
ko.pureComputed = (evaluatorFunctionOrOptions, evaluatorFunctionTarget) => {
|
||||
if (typeof evaluatorFunctionOrOptions === 'function') {
|
||||
|
|
@ -515,4 +505,3 @@ ko.pureComputed = (evaluatorFunctionOrOptions, evaluatorFunctionTarget) => {
|
|||
evaluatorFunctionOrOptions['pure'] = true;
|
||||
return ko.computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget);
|
||||
};
|
||||
ko.exportSymbol('pureComputed', ko.pureComputed);
|
||||
|
|
|
|||
|
|
@ -71,8 +71,5 @@ ko.isWriteableObservable = instance => {
|
|||
|
||||
ko.exportSymbol('observable', ko.observable);
|
||||
ko.exportSymbol('isObservable', ko.isObservable);
|
||||
ko.exportSymbol('isWriteableObservable', ko.isWriteableObservable);
|
||||
ko.exportSymbol('observable.fn', observableFn);
|
||||
ko.exportProperty(observableFn, 'peek', observableFn.peek);
|
||||
ko.exportProperty(observableFn, 'valueHasMutated', observableFn.valueHasMutated);
|
||||
ko.exportProperty(observableFn, 'valueWillMutate', observableFn.valueWillMutate);
|
||||
|
|
|
|||
|
|
@ -95,4 +95,3 @@ ko.isObservableArray = instance => {
|
|||
};
|
||||
|
||||
ko.exportSymbol('observableArray', ko.observableArray);
|
||||
ko.exportSymbol('isObservableArray', ko.isObservableArray);
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
ko.when = (predicate, callback, context) => {
|
||||
function kowhen (resolve) {
|
||||
var observable = ko.pureComputed(predicate, context).extend({notify:'always'});
|
||||
var subscription = observable.subscribe(value => {
|
||||
if (value) {
|
||||
subscription.dispose();
|
||||
resolve(value);
|
||||
}
|
||||
});
|
||||
// In case the initial value is true, process it right away
|
||||
observable['notifySubscribers'](observable.peek());
|
||||
|
||||
return subscription;
|
||||
}
|
||||
return callback ? kowhen(callback.bind(context)) : new Promise(kowhen);
|
||||
};
|
||||
|
||||
ko.exportSymbol('when', ko.when);
|
||||
|
|
@ -101,16 +101,16 @@ var ko_subscribable_fn = {
|
|||
|
||||
if (!self._origNotifySubscribers) {
|
||||
self._origNotifySubscribers = self["notifySubscribers"];
|
||||
// Moved out of "limit" to avoid the extra closure
|
||||
// Moved out of "limit" to avoid the extra closure
|
||||
self["notifySubscribers"] = function(value, event) {
|
||||
if (!event || event === defaultEvent) {
|
||||
this._limitChange(value);
|
||||
} else if (event === 'beforeChange') {
|
||||
this._limitBeforeChange(value);
|
||||
} else {
|
||||
this._origNotifySubscribers(value, event);
|
||||
}
|
||||
}
|
||||
if (!event || event === defaultEvent) {
|
||||
this._limitChange(value);
|
||||
} else if (event === 'beforeChange') {
|
||||
this._limitBeforeChange(value);
|
||||
} else {
|
||||
this._origNotifySubscribers(value, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var finish = limitFunction(() => {
|
||||
|
|
@ -196,6 +196,3 @@ ko.subscribable['fn'] = ko_subscribable_fn;
|
|||
|
||||
ko.isSubscribable = instance =>
|
||||
instance != null && typeof instance.subscribe == "function" && typeof instance["notifySubscribers"] == "function";
|
||||
|
||||
ko.exportSymbol('subscribable', ko.subscribable);
|
||||
ko.exportSymbol('isSubscribable', ko.isSubscribable);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue