Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81152 views
1
/**
2
* Copyright 2013-2014, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @providesModule ReactRAFBatchingStrategy
10
* @typechecks static-only
11
*/
12
13
"use strict";
14
15
var ExecutionEnvironment = require('ExecutionEnvironment');
16
var ReactUpdates = require('ReactUpdates');
17
18
var requestAnimationFrame = require('requestAnimationFrame');
19
20
function tick() {
21
ReactUpdates.flushBatchedUpdates();
22
requestAnimationFrame(tick);
23
}
24
25
var ReactRAFBatchingStrategy = {
26
isBatchingUpdates: true,
27
28
/**
29
* Call the provided function in a context within which calls to `setState`
30
* and friends are batched such that components aren't updated unnecessarily.
31
*/
32
batchedUpdates: function(callback, a, b) {
33
callback(a, b);
34
}
35
};
36
37
if (ExecutionEnvironment.canUseDOM) {
38
requestAnimationFrame(tick);
39
}
40
41
module.exports = ReactRAFBatchingStrategy;
42
43