More Knockout code to ES6

This commit is contained in:
djmaze 2021-07-29 11:43:47 +02:00
parent b7cb990b00
commit cbecdd93a0
22 changed files with 733 additions and 865 deletions

View file

@ -1,49 +1,44 @@
(() => {
ko.dependencyDetection = (() => {
var outerFrames = [],
currentFrame,
lastId = 0,
var outerFrames = [],
currentFrame,
lastId = 0,
begin = options => {
outerFrames.push(currentFrame);
currentFrame = options;
},
begin = options => {
outerFrames.push(currentFrame);
currentFrame = options;
},
end = () => currentFrame = outerFrames.pop();
end = () => currentFrame = outerFrames.pop();
return {
begin: begin,
ko.dependencyDetection = {
begin: begin,
end: end,
end: end,
registerDependency: subscribable => {
if (currentFrame) {
if (!ko.isSubscribable(subscribable))
throw new Error("Only subscribable things can act as dependencies");
currentFrame.callback.call(currentFrame.callbackTarget, subscribable,
subscribable._id || (subscribable._id = ++lastId));
}
},
ignore: (callback, callbackTarget, callbackArgs) => {
try {
begin();
return callback.apply(callbackTarget, callbackArgs || []);
} finally {
end();
}
},
getDependenciesCount: () => {
return currentFrame && currentFrame.computed.getDependenciesCount();
},
isInitial: () => {
return currentFrame && currentFrame.isInitial;
},
computed: () => {
return currentFrame && currentFrame.computed;
registerDependency: subscribable => {
if (currentFrame) {
if (!ko.isSubscribable(subscribable))
throw new Error("Only subscribable things can act as dependencies");
currentFrame.callback.call(currentFrame.callbackTarget, subscribable,
subscribable._id || (subscribable._id = ++lastId));
}
};
},
ignore: (callback, callbackTarget, callbackArgs) => {
try {
begin();
return callback.apply(callbackTarget, callbackArgs || []);
} finally {
end();
}
},
getDependenciesCount: () => currentFrame && currentFrame.computed.getDependenciesCount(),
isInitial: () => currentFrame && currentFrame.isInitial,
computed: () => currentFrame && currentFrame.computed
};
})();