2015-01-30 01:10:49 +00:00
|
|
|
/**
|
2015-03-23 22:07:33 +00:00
|
|
|
* Copyright (c) 2015-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.
|
2015-01-30 01:10:49 +00:00
|
|
|
*
|
2015-05-08 16:45:43 +00:00
|
|
|
* @providesModule ReactNativeReconcileTransaction
|
2015-03-25 02:34:12 +00:00
|
|
|
* @flow
|
2015-01-30 01:10:49 +00:00
|
|
|
*/
|
2015-05-19 20:43:46 +00:00
|
|
|
'use strict';
|
2015-01-30 01:10:49 +00:00
|
|
|
|
|
|
|
var CallbackQueue = require('CallbackQueue');
|
|
|
|
var PooledClass = require('PooledClass');
|
|
|
|
var Transaction = require('Transaction');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks during
|
|
|
|
* the performing of the transaction.
|
|
|
|
*/
|
|
|
|
var ON_DOM_READY_QUEUEING = {
|
|
|
|
/**
|
|
|
|
* Initializes the internal `onDOMReady` queue.
|
|
|
|
*/
|
|
|
|
initialize: function() {
|
|
|
|
this.reactMountReady.reset();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* After DOM is flushed, invoke all registered `onDOMReady` callbacks.
|
|
|
|
*/
|
|
|
|
close: function() {
|
|
|
|
this.reactMountReady.notifyAll();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Executed within the scope of the `Transaction` instance. Consider these as
|
|
|
|
* being member methods, but with an implied ordering while being isolated from
|
|
|
|
* each other.
|
|
|
|
*/
|
|
|
|
var TRANSACTION_WRAPPERS = [ON_DOM_READY_QUEUEING];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Currently:
|
|
|
|
* - The order that these are listed in the transaction is critical:
|
|
|
|
* - Suppresses events.
|
|
|
|
* - Restores selection range.
|
|
|
|
*
|
|
|
|
* Future:
|
|
|
|
* - Restore document/overflow scroll positions that were unintentionally
|
|
|
|
* modified via DOM insertions above the top viewport boundary.
|
|
|
|
* - Implement/integrate with customized constraint based layout system and keep
|
|
|
|
* track of which dimensions must be remeasured.
|
|
|
|
*
|
2015-05-08 16:45:43 +00:00
|
|
|
* @class ReactNativeReconcileTransaction
|
2015-01-30 01:10:49 +00:00
|
|
|
*/
|
2015-05-08 16:45:43 +00:00
|
|
|
function ReactNativeReconcileTransaction() {
|
2015-01-30 01:10:49 +00:00
|
|
|
this.reinitializeTransaction();
|
|
|
|
this.reactMountReady = CallbackQueue.getPooled(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
var Mixin = {
|
|
|
|
/**
|
|
|
|
* @see Transaction
|
|
|
|
* @abstract
|
|
|
|
* @final
|
|
|
|
* @return {array<object>} List of operation wrap proceedures.
|
|
|
|
* TODO: convert to array<TransactionWrapper>
|
|
|
|
*/
|
|
|
|
getTransactionWrappers: function() {
|
|
|
|
return TRANSACTION_WRAPPERS;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {object} The queue to collect `onDOMReady` callbacks with.
|
|
|
|
* TODO: convert to ReactMountReady
|
|
|
|
*/
|
|
|
|
getReactMountReady: function() {
|
|
|
|
return this.reactMountReady;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* `PooledClass` looks for this, and will invoke this before allowing this
|
|
|
|
* instance to be resused.
|
|
|
|
*/
|
|
|
|
destructor: function() {
|
|
|
|
CallbackQueue.release(this.reactMountReady);
|
|
|
|
this.reactMountReady = null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Object.assign(
|
2015-05-08 16:45:43 +00:00
|
|
|
ReactNativeReconcileTransaction.prototype,
|
2015-01-30 01:10:49 +00:00
|
|
|
Transaction.Mixin,
|
2015-05-08 16:45:43 +00:00
|
|
|
ReactNativeReconcileTransaction,
|
2015-01-30 01:10:49 +00:00
|
|
|
Mixin
|
|
|
|
);
|
|
|
|
|
2015-05-08 16:45:43 +00:00
|
|
|
PooledClass.addPoolingTo(ReactNativeReconcileTransaction);
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2015-05-08 16:45:43 +00:00
|
|
|
module.exports = ReactNativeReconcileTransaction;
|