UNPKG

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