Skip to content

Commit 8b7a0c2

Browse files
fkgozalifacebook-github-bot
authored andcommitted
Created spec for SegmentFetcher native module
Summary: [General] [Added] - Simply adding spec for better enforcement of types. Reviewed By: cpojer Differential Revision: D14177690 fbshipit-source-id: ab4c112d1bd65fef7e37b4c1d6c44055f5576936
1 parent e758435 commit 8b7a0c2

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow strict-local
8+
* @format
9+
*/
10+
'use strict';
11+
12+
import type {TurboModule} from 'RCTExport';
13+
import * as TurboModuleRegistry from 'TurboModuleRegistry';
14+
15+
export interface Spec extends TurboModule {
16+
+fetchSegment: (
17+
segmentId: number,
18+
options: Object, // flowlint-line unclear-type: off
19+
callback: (error: ?Object) => void, // flowlint-line unclear-type: off
20+
) => void;
21+
}
22+
23+
export default TurboModuleRegistry.getEnforcing<Spec>('SegmentFetcher');

Libraries/Core/setUpSegmentFetcher.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@ global.__fetchSegment = function(
1818
options: {|+otaBuildNumber: ?string|},
1919
callback: (?Error) => void,
2020
) {
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-
21+
const SegmentFetcher = require('NativeSegmentFetcher').default;
2922
SegmentFetcher.fetchSegment(
3023
segmentId,
3124
options,

0 commit comments

Comments
 (0)