UNPKG

1.24 kBJavaScriptView Raw
1/**
2 * React Blessed Specific React Transaction
3 * =========================================
4 *
5 * React custom reconcile transaction injected by the renderer to enable
6 * updates.
7 *
8 * NOTE: This looks more like a shim than the proper thing actually.
9 */
10import CallbackQueue from 'react/lib/CallbackQueue';
11import PooledClass from 'react/lib/PooledClass';
12import Transaction from 'react/lib/Transaction';
13import {extend} from 'lodash';
14
15const ON_BLESSED_READY_QUEUEING = {
16 initialize: function () {
17 this.reactMountReady.reset();
18 },
19 close: function () {
20 this.reactMountReady.notifyAll();
21 }
22};
23
24function ReactBlessedReconcileTransaction() {
25 this.reinitializeTransaction();
26 this.reactMountReady = CallbackQueue.getPooled(null);
27}
28
29const Mixin = {
30 getTransactionWrappers: function() {
31 return [ON_BLESSED_READY_QUEUEING];
32 },
33 getReactMountReady: function() {
34 return this.reactMountReady;
35 },
36 destructor: function() {
37 CallbackQueue.release(this.reactMountReady);
38 this.reactMountReady = null;
39 }
40};
41
42extend(
43 ReactBlessedReconcileTransaction.prototype,
44 Transaction.Mixin,
45 Mixin
46);
47
48PooledClass.addPoolingTo(ReactBlessedReconcileTransaction);
49
50export default ReactBlessedReconcileTransaction;