1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | 'use strict';
|
10 |
|
11 | var _assign = require('object-assign');
|
12 |
|
13 | var ReactUpdates = require('./ReactUpdates');
|
14 | var Transaction = require('./Transaction');
|
15 |
|
16 | var emptyFunction = require('fbjs/lib/emptyFunction');
|
17 |
|
18 | var RESET_BATCHED_UPDATES = {
|
19 | initialize: emptyFunction,
|
20 | close: function () {
|
21 | ReactDefaultBatchingStrategy.isBatchingUpdates = false;
|
22 | }
|
23 | };
|
24 |
|
25 | var FLUSH_BATCHED_UPDATES = {
|
26 | initialize: emptyFunction,
|
27 | close: ReactUpdates.flushBatchedUpdates.bind(ReactUpdates)
|
28 | };
|
29 |
|
30 | var TRANSACTION_WRAPPERS = [FLUSH_BATCHED_UPDATES, RESET_BATCHED_UPDATES];
|
31 |
|
32 | function ReactDefaultBatchingStrategyTransaction() {
|
33 | this.reinitializeTransaction();
|
34 | }
|
35 |
|
36 | _assign(ReactDefaultBatchingStrategyTransaction.prototype, Transaction, {
|
37 | getTransactionWrappers: function () {
|
38 | return TRANSACTION_WRAPPERS;
|
39 | }
|
40 | });
|
41 |
|
42 | var transaction = new ReactDefaultBatchingStrategyTransaction();
|
43 |
|
44 | var ReactDefaultBatchingStrategy = {
|
45 | isBatchingUpdates: false,
|
46 |
|
47 | |
48 |
|
49 |
|
50 |
|
51 | batchedUpdates: function (callback, a, b, c, d, e) {
|
52 | var alreadyBatchingUpdates = ReactDefaultBatchingStrategy.isBatchingUpdates;
|
53 |
|
54 | ReactDefaultBatchingStrategy.isBatchingUpdates = true;
|
55 |
|
56 |
|
57 | if (alreadyBatchingUpdates) {
|
58 | return callback(a, b, c, d, e);
|
59 | } else {
|
60 | return transaction.perform(callback, null, a, b, c, d, e);
|
61 | }
|
62 | }
|
63 | };
|
64 |
|
65 | module.exports = ReactDefaultBatchingStrategy; |
\ | No newline at end of file |