forked from ferrannp/react-native-sync-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (24 loc) · 751 Bytes
/
index.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
/* @flow */
import {NativeModules} from 'react-native';
const SyncAdapter = NativeModules.SyncAdapter;
type Init = {
syncInterval: number,
syncFlexTime: number,
};
const _checkIntervals = (syncInterval: number, syncFlexTime: number) => {
if (syncFlexTime > syncInterval) {
throw new Error(
'Specified syncInterval must be greater than the specified syncFlexTime.',
);
}
};
export default {
init: ({syncInterval, syncFlexTime}: Init) => {
_checkIntervals(syncInterval, syncFlexTime);
SyncAdapter.init(syncInterval, syncFlexTime);
},
syncImmediately: ({syncInterval, syncFlexTime}: Init) => {
_checkIntervals(syncInterval, syncFlexTime);
SyncAdapter.syncImmediately(syncInterval, syncFlexTime);
},
};