Created
August 29, 2016 03:41
-
-
Save vjeux/3f93542da5a9f842dc0a240bf44870f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(e, t, n) { | |
"use strict"; | |
function o() { | |
this._callbacks = null, this._contexts = null | |
} | |
var r = e(115), | |
a = e(147), | |
i = e(25); | |
e(139); | |
a(o.prototype, { | |
enqueue: function(e, t) { | |
this._callbacks = this._callbacks || [], this._contexts = this._contexts || [], this._callbacks.push(e), this._contexts.push(t) | |
}, | |
notifyAll: function() { | |
var e = this._callbacks, | |
t = this._contexts; | |
if (e) { | |
e.length !== t.length ? r("24") : void 0, this._callbacks = null, this._contexts = null; | |
for (var n = 0; n < e.length; n++) e[n].call(t[n]); | |
e.length = 0, t.length = 0 | |
} | |
}, | |
checkpoint: function() { | |
return this._callbacks ? this._callbacks.length : 0 | |
}, | |
rollback: function(e) { | |
this._callbacks && (this._callbacks.length = e, this._contexts.length = e) | |
}, | |
reset: function() { | |
this._callbacks = null, this._contexts = null | |
}, | |
destructor: function() { | |
this.reset() | |
} | |
}), t.exports = i.addPoolingTo(o) | |
}, { | |
115: 115, | |
139: 139, | |
147: 147, | |
25: 25 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule CallbackQueue | |
* @flow | |
*/ | |
'use strict'; | |
var PooledClass = require('PooledClass'); | |
var invariant = require('invariant'); | |
/** | |
* A specialized pseudo-event module to help keep track of components waiting to | |
* be notified when their DOM representations are available for use. | |
* | |
* This implements `PooledClass`, so you should never need to instantiate this. | |
* Instead, use `CallbackQueue.getPooled()`. | |
* | |
* @class ReactMountReady | |
* @implements PooledClass | |
* @internal | |
*/ | |
function CallbackQueue() { | |
this._callbacks = null; | |
this._contexts = null; | |
} | |
Object.assign(CallbackQueue.prototype, { | |
/** | |
* Enqueues a callback to be invoked when `notifyAll` is invoked. | |
* | |
* @param {function} callback Invoked when `notifyAll` is invoked. | |
* @param {?object} context Context to call `callback` with. | |
* @internal | |
*/ | |
enqueue: function(callback, context) { | |
this._callbacks = this._callbacks || []; | |
this._contexts = this._contexts || []; | |
this._callbacks.push(callback); | |
this._contexts.push(context); | |
}, | |
/** | |
* Invokes all enqueued callbacks and clears the queue. This is invoked after | |
* the DOM representation of a component has been created or updated. | |
* | |
* @internal | |
*/ | |
notifyAll: function() { | |
var callbacks = this._callbacks; | |
var contexts = this._contexts; | |
if (callbacks) { | |
invariant( | |
callbacks.length === contexts.length, | |
'Mismatched list of contexts in callback queue' | |
); | |
this._callbacks = null; | |
this._contexts = null; | |
for (var i = 0; i < callbacks.length; i++) { | |
callbacks[i].call(contexts[i]); | |
} | |
callbacks.length = 0; | |
contexts.length = 0; | |
} | |
}, | |
checkpoint: function() { | |
return this._callbacks ? this._callbacks.length : 0; | |
}, | |
rollback: function(len) { | |
if (this._callbacks) { | |
this._callbacks.length = len; | |
this._contexts.length = len; | |
} | |
}, | |
/** | |
* Resets the internal queue. | |
* | |
* @internal | |
*/ | |
reset: function() { | |
this._callbacks = null; | |
this._contexts = null; | |
}, | |
/** | |
* `PooledClass` looks for this. | |
*/ | |
destructor: function() { | |
this.reset(); | |
}, | |
}); | |
module.exports = PooledClass.addPoolingTo(CallbackQueue); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(e, t, n) { | |
"use strict"; | |
function o(e, t) { | |
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") | |
} | |
var r = e(115), | |
a = e(25), | |
i = (e(139), function() { | |
function e() { | |
o(this, e), this._callbacks = null, this._contexts = null | |
} | |
return e.prototype.enqueue = function(e, t) { | |
this._callbacks = this._callbacks || [], this._callbacks.push(e), this._contexts = this._contexts || [], this._contexts.push(t) | |
}, e.prototype.notifyAll = function() { | |
var e = this._callbacks, | |
t = this._contexts; | |
if (e && t) { | |
e.length !== t.length ? r("24") : void 0, this._callbacks = null, this._contexts = null; | |
for (var n = 0; n < e.length; n++) e[n].call(t[n]); | |
e.length = 0, t.length = 0 | |
} | |
}, e.prototype.checkpoint = function() { | |
return this._callbacks ? this._callbacks.length : 0 | |
}, e.prototype.rollback = function(e) { | |
this._callbacks && this._contexts && (this._callbacks.length = e, this._contexts.length = e) | |
}, e.prototype.reset = function() { | |
this._callbacks = null, this._contexts = null | |
}, e.prototype.destructor = function() { | |
this.reset() | |
}, e | |
}()); | |
t.exports = a.addPoolingTo(i) | |
}, { | |
115: 115, | |
139: 139, | |
25: 25 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule CallbackQueue | |
* @flow | |
*/ | |
'use strict'; | |
var PooledClass = require('PooledClass'); | |
var invariant = require('invariant'); | |
/** | |
* A specialized pseudo-event module to help keep track of components waiting to | |
* be notified when their DOM representations are available for use. | |
* | |
* This implements `PooledClass`, so you should never need to instantiate this. | |
* Instead, use `CallbackQueue.getPooled()`. | |
* | |
* @class ReactMountReady | |
* @implements PooledClass | |
* @internal | |
*/ | |
class CallbackQueue<T> { | |
_callbacks: ?Array<() => void>; | |
_contexts: ?Array<T>; | |
constructor() { | |
this._callbacks = null; | |
this._contexts = null; | |
} | |
/** | |
* Enqueues a callback to be invoked when `notifyAll` is invoked. | |
* | |
* @param {function} callback Invoked when `notifyAll` is invoked. | |
* @param {?object} context Context to call `callback` with. | |
* @internal | |
*/ | |
enqueue(callback: () => void, context: T) { | |
this._callbacks = this._callbacks || []; | |
this._callbacks.push(callback); | |
this._contexts = this._contexts || []; | |
this._contexts.push(context); | |
}; | |
/** | |
* Invokes all enqueued callbacks and clears the queue. This is invoked after | |
* the DOM representation of a component has been created or updated. | |
* | |
* @internal | |
*/ | |
notifyAll() { | |
var callbacks = this._callbacks; | |
var contexts = this._contexts; | |
if (callbacks && contexts) { | |
invariant( | |
callbacks.length === contexts.length, | |
'Mismatched list of contexts in callback queue' | |
); | |
this._callbacks = null; | |
this._contexts = null; | |
for (var i = 0; i < callbacks.length; i++) { | |
callbacks[i].call(contexts[i]); | |
} | |
callbacks.length = 0; | |
contexts.length = 0; | |
} | |
} | |
checkpoint() { | |
return this._callbacks ? this._callbacks.length : 0; | |
} | |
rollback(len: number) { | |
if (this._callbacks && this._contexts) { | |
this._callbacks.length = len; | |
this._contexts.length = len; | |
} | |
} | |
/** | |
* Resets the internal queue. | |
* | |
* @internal | |
*/ | |
reset() { | |
this._callbacks = null; | |
this._contexts = null; | |
} | |
/** | |
* `PooledClass` looks for this. | |
*/ | |
destructor() { | |
this.reset(); | |
} | |
} | |
module.exports = PooledClass.addPoolingTo(CallbackQueue); |
Author
vjeux
commented
Aug 30, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment