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