react-native: BundleSegments: remove async/await
Reviewed By: fromcelticpark Differential Revision: D6508646 fbshipit-source-id: 9e5c05bde5420cb030912eb187f6333af4b580f9
This commit is contained in:
parent
9f33fe2583
commit
1988ba1d79
|
@ -20,15 +20,18 @@ let segmentLoaders = new Map();
|
|||
* its module. We cache load promises so as to avoid calling `fetchSegment` twice
|
||||
* for the same bundle. We assume that once a segment is fetched/loaded, it is
|
||||
* never gettting removed during this instance of the JavaScript VM.
|
||||
*
|
||||
* We don't use async/await syntax to avoid depending on `regeneratorRuntime`.
|
||||
*/
|
||||
async function loadForModule(moduleID: number): Promise<void> {
|
||||
function loadForModule(moduleID: number): Promise<void> {
|
||||
return Promise.resolve().then(() => {
|
||||
const {segmentId} = (require: $FlowFixMe).unpackModuleId(moduleID);
|
||||
if (segmentId === 0) {
|
||||
return;
|
||||
}
|
||||
let segmentLoader = segmentLoaders.get(segmentId);
|
||||
if (segmentLoader != null) {
|
||||
return await segmentLoader;
|
||||
return segmentLoader;
|
||||
}
|
||||
|
||||
const {fetchSegment} = global;
|
||||
|
@ -48,7 +51,8 @@ async function loadForModule(moduleID: number): Promise<void> {
|
|||
});
|
||||
});
|
||||
segmentLoaders.set(segmentId, segmentLoader);
|
||||
return await segmentLoader;
|
||||
return segmentLoader;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {loadForModule};
|
||||
|
|
Loading…
Reference in New Issue