-
Notifications
You must be signed in to change notification settings - Fork 54
/
RCTRefreshControl.ios.js
49 lines (41 loc) · 1.08 KB
/
RCTRefreshControl.ios.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* @providesModule RCTRefreshControl
* @flow
*/
'use strict';
var React = require('react-native');
var {
DeviceEventEmitter,
NativeModules: {
RefreshControl,
}
} = React;
/**
* A pull down to refresh control like the one in Apple's iOS6 Mail App.
*/
var DROP_VIEW_DID_BEGIN_REFRESHING_EVENT = 'dropViewDidBeginRefreshing';
var callbacks = {};
var subscription = DeviceEventEmitter.addListener(
DROP_VIEW_DID_BEGIN_REFRESHING_EVENT,
(reactTag) => callbacks[reactTag]()
);
// subscription.remove();
var RCTRefreshControl = {
configure: function(configs, callback) {
var nodeHandle = React.findNodeHandle(configs.node);
var options = {
tintColor: configs.tintColor,
activityIndicatorViewColor: configs.activityIndicatorViewColor
};
RefreshControl.configure(nodeHandle, options, (error) => {
if (!error) {
callbacks[nodeHandle] = callback;
}
});
},
endRefreshing: function(node) {
var nodeHandle = React.findNodeHandle(node);
RefreshControl.endRefreshing(nodeHandle);
}
};
module.exports = RCTRefreshControl;