react / react-0.13.3 / examples / basic-commonjs / node_modules / reactify / node_modules / react-tools / src / browser / server / ReactServerRenderingTransaction.js
81158 views/**1* Copyright 2014, Facebook, Inc.2* All rights reserved.3*4* This source code is licensed under the BSD-style license found in the5* LICENSE file in the root directory of this source tree. An additional grant6* of patent rights can be found in the PATENTS file in the same directory.7*8* @providesModule ReactServerRenderingTransaction9* @typechecks10*/1112"use strict";1314var PooledClass = require('PooledClass');15var CallbackQueue = require('CallbackQueue');16var ReactPutListenerQueue = require('ReactPutListenerQueue');17var Transaction = require('Transaction');1819var assign = require('Object.assign');20var emptyFunction = require('emptyFunction');2122/**23* Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks24* during the performing of the transaction.25*/26var ON_DOM_READY_QUEUEING = {27/**28* Initializes the internal `onDOMReady` queue.29*/30initialize: function() {31this.reactMountReady.reset();32},3334close: emptyFunction35};3637var PUT_LISTENER_QUEUEING = {38initialize: function() {39this.putListenerQueue.reset();40},4142close: emptyFunction43};4445/**46* Executed within the scope of the `Transaction` instance. Consider these as47* being member methods, but with an implied ordering while being isolated from48* each other.49*/50var TRANSACTION_WRAPPERS = [51PUT_LISTENER_QUEUEING,52ON_DOM_READY_QUEUEING53];5455/**56* @class ReactServerRenderingTransaction57* @param {boolean} renderToStaticMarkup58*/59function ReactServerRenderingTransaction(renderToStaticMarkup) {60this.reinitializeTransaction();61this.renderToStaticMarkup = renderToStaticMarkup;62this.reactMountReady = CallbackQueue.getPooled(null);63this.putListenerQueue = ReactPutListenerQueue.getPooled();64}6566var Mixin = {67/**68* @see Transaction69* @abstract70* @final71* @return {array} Empty list of operation wrap proceedures.72*/73getTransactionWrappers: function() {74return TRANSACTION_WRAPPERS;75},7677/**78* @return {object} The queue to collect `onDOMReady` callbacks with.79*/80getReactMountReady: function() {81return this.reactMountReady;82},8384getPutListenerQueue: function() {85return this.putListenerQueue;86},8788/**89* `PooledClass` looks for this, and will invoke this before allowing this90* instance to be resused.91*/92destructor: function() {93CallbackQueue.release(this.reactMountReady);94this.reactMountReady = null;9596ReactPutListenerQueue.release(this.putListenerQueue);97this.putListenerQueue = null;98}99};100101102assign(103ReactServerRenderingTransaction.prototype,104Transaction.Mixin,105Mixin106);107108PooledClass.addPoolingTo(ReactServerRenderingTransaction);109110module.exports = ReactServerRenderingTransaction;111112113