mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 13:09:21 +03:00
More Knockout code to ES6
This commit is contained in:
parent
b7cb990b00
commit
cbecdd93a0
22 changed files with 733 additions and 865 deletions
|
|
@ -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
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue