Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/renderers/dom/shared/ReactEventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var EventListener = require('EventListener');
var ExecutionEnvironment = require('ExecutionEnvironment');
var PooledClass = require('PooledClass');
var ReactDOMComponentTree = require('ReactDOMComponentTree');
var ReactUpdates = require('ReactUpdates');
var ReactGenericBatching = require('ReactGenericBatching');

var getEventTarget = require('getEventTarget');
var getUnboundedScrollPosition = require('getUnboundedScrollPosition');
Expand Down Expand Up @@ -165,7 +165,7 @@ var ReactEventListener = {
try {
// Event queue being processed in the same cycle allows
// `preventDefault`.
ReactUpdates.batchedUpdates(handleTopLevelImpl, bookKeeping);
ReactGenericBatching.batchedUpdates(handleTopLevelImpl, bookKeeping);
} finally {
TopLevelCallbackBookKeeping.release(bookKeeping);
}
Expand Down
4 changes: 2 additions & 2 deletions src/renderers/dom/shared/eventPlugins/ChangeEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var EventPluginHub = require('EventPluginHub');
var EventPropagators = require('EventPropagators');
var ExecutionEnvironment = require('ExecutionEnvironment');
var ReactDOMComponentTree = require('ReactDOMComponentTree');
var ReactUpdates = require('ReactUpdates');
var ReactGenericBatching = require('ReactGenericBatching');
var SyntheticEvent = require('SyntheticEvent');

var inputValueTracking = require('inputValueTracking');
Expand Down Expand Up @@ -98,7 +98,7 @@ function manualDispatchChangeEvent(nativeEvent) {
// components don't work properly in conjunction with event bubbling because
// the component is rerendered and the value reverted before all the event
// handlers can run. See https://github.com/facebook/react/issues/708.
ReactUpdates.batchedUpdates(runEventInBatch, event);
ReactGenericBatching.batchedUpdates(runEventInBatch, event);
}

function runEventInBatch(event) {
Expand Down
5 changes: 5 additions & 0 deletions src/renderers/dom/stack/client/ReactDOMStackInjection.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var ReactDOMEmptyComponent = require('ReactDOMEmptyComponent');
var ReactDOMTextComponent = require('ReactDOMTextComponent');
var ReactDefaultBatchingStrategy = require('ReactDefaultBatchingStrategy');
var ReactEmptyComponent = require('ReactEmptyComponent');
var ReactGenericBatching = require('ReactGenericBatching');
var ReactHostComponent = require('ReactHostComponent');
var ReactReconcileTransaction = require('ReactReconcileTransaction');
var ReactUpdates = require('ReactUpdates');
Expand All @@ -34,6 +35,10 @@ function inject() {
}
alreadyInjected = true;

ReactGenericBatching.injection.injectStackBatchedUpdates(
ReactUpdates.batchedUpdates
);

ReactHostComponent.injection.injectGenericComponentClass(
ReactDOMComponent
);
Expand Down
4 changes: 2 additions & 2 deletions src/renderers/native/ReactNativeEventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var EventPluginRegistry = require('EventPluginRegistry');
var ReactEventEmitterMixin = require('ReactEventEmitterMixin');
var ReactNativeComponentTree = require('ReactNativeComponentTree');
var ReactNativeTagHandles = require('ReactNativeTagHandles');
var ReactUpdates = require('ReactUpdates');
var ReactGenericBatching = require('ReactGenericBatching');

var warning = require('warning');

Expand Down Expand Up @@ -123,7 +123,7 @@ var ReactNativeEventEmitter = {
// any events.
return;
}
ReactUpdates.batchedUpdates(function() {
ReactGenericBatching.batchedUpdates(function() {
ReactNativeEventEmitter.handleTopLevel(
topLevelType,
inst,
Expand Down
5 changes: 5 additions & 0 deletions src/renderers/native/ReactNativeStackInjection.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var React = require('React');
var ReactComponentEnvironment = require('ReactComponentEnvironment');
var ReactDefaultBatchingStrategy = require('ReactDefaultBatchingStrategy');
var ReactEmptyComponent = require('ReactEmptyComponent');
var ReactGenericBatching = require('ReactGenericBatching');
var ReactHostComponent = require('ReactHostComponent');
var ReactNativeComponentEnvironment = require('ReactNativeComponentEnvironment');
var ReactNativeTextComponent = require('ReactNativeTextComponent');
Expand All @@ -32,6 +33,10 @@ var ReactUpdates = require('ReactUpdates');
var invariant = require('invariant');

function inject() {
ReactGenericBatching.injection.injectStackBatchedUpdates(
ReactUpdates.batchedUpdates
);

ReactUpdates.injection.injectReconcileTransaction(
ReactNativeComponentEnvironment.ReactReconcileTransaction
);
Expand Down
53 changes: 53 additions & 0 deletions src/renderers/shared/shared/event/ReactGenericBatching.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Copyright 2013-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.
*
* @providesModule ReactGenericBatching
*/

'use strict';

// Used as a way to call batchedUpdates when we don't know if we're in a Fiber
// or Stack context. Such as when we're dispatching events or if third party
// libraries need to call batchedUpdates. Eventually, this API will go away when
// everything is batched by default. We'll then have a similar API to opt-out of
// scheduled work and instead do synchronous work.

// Defaults
var stackBatchedUpdates = function(fn, a, b, c, d, e) {
fn(a, b, c, d, e);
};
var fiberPerformSynchronousWork = function(fn, bookkeeping) {
fn(bookkeeping);
};

function performFiberBatchedUpdates(fn, bookkeeping) {
// If we have Fiber loaded, we need to wrap this in a batching call so that
// Fiber can apply its default priority for this call.
fiberPerformSynchronousWork(fn, bookkeeping);
}
function batchedUpdates(fn, bookkeeping) {
// We first perform work with the stack batching strategy, by passing our
// indirection to it.
stackBatchedUpdates(performFiberBatchedUpdates, fn, bookkeeping);
}

var ReactGenericBatchingInjection = {
injectStackBatchedUpdates: function(_batchedUpdates) {
stackBatchedUpdates = _batchedUpdates;
},
injectFiberPerformSynchronousWork: function(_performSynchronousWork) {
fiberPerformSynchronousWork = _performSynchronousWork;
},
};

var ReactGenericBatching = {
batchedUpdates,
injection: ReactGenericBatchingInjection,
};

module.exports = ReactGenericBatching;
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ function noResponderTouches(nativeEvent) {
var ResponderEventPlugin = {

/* For unit testing only */
_getResponderID: function() {
return responderInst ? responderInst._rootNodeID : null;
_getResponder: function() {
return responderInst;
},

eventTypes: eventTypes,
Expand Down
Loading