UNPKG

2.17 kBJavaScriptView Raw
1/**
2 * Copyright (c) 2014-present, Facebook, Inc.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 */
8
9'use strict';
10
11var _assign = require('object-assign');
12
13var PooledClass = require('./PooledClass');
14var Transaction = require('./Transaction');
15var ReactInstrumentation = require('./ReactInstrumentation');
16var ReactServerUpdateQueue = require('./ReactServerUpdateQueue');
17
18/**
19 * Executed within the scope of the `Transaction` instance. Consider these as
20 * being member methods, but with an implied ordering while being isolated from
21 * each other.
22 */
23var TRANSACTION_WRAPPERS = [];
24
25if (process.env.NODE_ENV !== 'production') {
26 TRANSACTION_WRAPPERS.push({
27 initialize: ReactInstrumentation.debugTool.onBeginFlush,
28 close: ReactInstrumentation.debugTool.onEndFlush
29 });
30}
31
32var noopCallbackQueue = {
33 enqueue: function () {}
34};
35
36/**
37 * @class ReactServerRenderingTransaction
38 * @param {boolean} renderToStaticMarkup
39 */
40function ReactServerRenderingTransaction(renderToStaticMarkup) {
41 this.reinitializeTransaction();
42 this.renderToStaticMarkup = renderToStaticMarkup;
43 this.useCreateElement = false;
44 this.updateQueue = new ReactServerUpdateQueue(this);
45}
46
47var Mixin = {
48 /**
49 * @see Transaction
50 * @abstract
51 * @final
52 * @return {array} Empty list of operation wrap procedures.
53 */
54 getTransactionWrappers: function () {
55 return TRANSACTION_WRAPPERS;
56 },
57
58 /**
59 * @return {object} The queue to collect `onDOMReady` callbacks with.
60 */
61 getReactMountReady: function () {
62 return noopCallbackQueue;
63 },
64
65 /**
66 * @return {object} The queue to collect React async events.
67 */
68 getUpdateQueue: function () {
69 return this.updateQueue;
70 },
71
72 /**
73 * `PooledClass` looks for this, and will invoke this before allowing this
74 * instance to be reused.
75 */
76 destructor: function () {},
77
78 checkpoint: function () {},
79
80 rollback: function () {}
81};
82
83_assign(ReactServerRenderingTransaction.prototype, Transaction, Mixin);
84
85PooledClass.addPoolingTo(ReactServerRenderingTransaction);
86
87module.exports = ReactServerRenderingTransaction;
\No newline at end of file