Sha256: d11349278038b7b13667f49a64fdd55dd369990428c913cbe7bdad90bb3610d6
Contents?: true
Size: 1018 Bytes
Versions: 37
Compression:
Stored size: 1018 Bytes
Contents
goog.provide('webfont.StyleSheetWaiter'); /** * A utility class for handling callback from DomHelper.loadStylesheet(). * * @constructor */ webfont.StyleSheetWaiter = function() { /** @private @type {number} */ this.waitingCount_ = 0; /** @private @type {Function} */ this.onReady_ = null; }; goog.scope(function () { var StyleSheetWaiter = webfont.StyleSheetWaiter; /** * @return {function(Error)} */ StyleSheetWaiter.prototype.startWaitingLoad = function() { var self = this; self.waitingCount_++; return function(error) { self.waitingCount_--; self.fireIfReady_(); }; }; /** * @param {Function} fn */ StyleSheetWaiter.prototype.waitWhileNeededThen = function(fn) { this.onReady_ = fn; this.fireIfReady_(); }; /** * @private */ StyleSheetWaiter.prototype.fireIfReady_ = function() { var isReady = 0 == this.waitingCount_; if (isReady && this.onReady_) { this.onReady_(); this.onReady_ = null; } }; });
Version data entries
37 entries across 37 versions & 3 rubygems