mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 14:07:04 +03:00
Clone 3.5.1 from github
This commit is contained in:
parent
5d281486d0
commit
091c4ec811
65 changed files with 6957 additions and 7 deletions
76
vendors/knockout/src/subscribables/dependencyDetection.js
vendored
Normal file
76
vendors/knockout/src/subscribables/dependencyDetection.js
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
|
||||
ko.computedContext = ko.dependencyDetection = (function () {
|
||||
var outerFrames = [],
|
||||
currentFrame,
|
||||
lastId = 0;
|
||||
|
||||
// Return a unique ID that can be assigned to an observable for dependency tracking.
|
||||
// Theoretically, you could eventually overflow the number storage size, resulting
|
||||
// in duplicate IDs. But in JavaScript, the largest exact integral value is 2^53
|
||||
// or 9,007,199,254,740,992. If you created 1,000,000 IDs per second, it would
|
||||
// take over 285 years to reach that number.
|
||||
// Reference http://blog.vjeux.com/2010/javascript/javascript-max_int-number-limits.html
|
||||
function getId() {
|
||||
return ++lastId;
|
||||
}
|
||||
|
||||
function begin(options) {
|
||||
outerFrames.push(currentFrame);
|
||||
currentFrame = options;
|
||||
}
|
||||
|
||||
function end() {
|
||||
currentFrame = outerFrames.pop();
|
||||
}
|
||||
|
||||
return {
|
||||
begin: begin,
|
||||
|
||||
end: end,
|
||||
|
||||
registerDependency: function (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 = getId()));
|
||||
}
|
||||
},
|
||||
|
||||
ignore: function (callback, callbackTarget, callbackArgs) {
|
||||
try {
|
||||
begin();
|
||||
return callback.apply(callbackTarget, callbackArgs || []);
|
||||
} finally {
|
||||
end();
|
||||
}
|
||||
},
|
||||
|
||||
getDependenciesCount: function () {
|
||||
if (currentFrame)
|
||||
return currentFrame.computed.getDependenciesCount();
|
||||
},
|
||||
|
||||
getDependencies: function () {
|
||||
if (currentFrame)
|
||||
return currentFrame.computed.getDependencies();
|
||||
},
|
||||
|
||||
isInitial: function() {
|
||||
if (currentFrame)
|
||||
return currentFrame.isInitial;
|
||||
},
|
||||
|
||||
computed: function() {
|
||||
if (currentFrame)
|
||||
return currentFrame.computed;
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
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);
|
||||
Loading…
Add table
Add a link
Reference in a new issue