1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | global.__fetchSegment = function(
|
17 | segmentId: number,
|
18 | options: {|+otaBuildNumber: ?string|},
|
19 | callback: (?Error) => void,
|
20 | ) {
|
21 | const {SegmentFetcher} = require('NativeModules');
|
22 | if (!SegmentFetcher) {
|
23 | throw new Error(
|
24 | 'SegmentFetcher is missing. Please ensure that it is ' +
|
25 | 'included as a NativeModule.',
|
26 | );
|
27 | }
|
28 |
|
29 | SegmentFetcher.fetchSegment(
|
30 | segmentId,
|
31 | options,
|
32 | (errorObject: ?{message: string, code: string}) => {
|
33 | if (errorObject) {
|
34 | const error = new Error(errorObject.message);
|
35 | (error: any).code = errorObject.code;
|
36 | callback(error);
|
37 | }
|
38 |
|
39 | callback(null);
|
40 | },
|
41 | );
|
42 | };
|