-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CP-8525: Improve Android performance (polyfill promise with es6-promi…
…se) (#1293)
- Loading branch information
Showing
5 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// there seems to be a performance issue with React Native's promise so we are polyfilling it with es6-promise | ||
// TODO: remove this polyfill and use bridgeless mode https://ava-labs.atlassian.net/browse/CP-8616 | ||
const { | ||
polyfillGlobal | ||
} = require('react-native/Libraries/Utilities/PolyfillFunctions') | ||
|
||
const Promise = require('es6-promise').Promise | ||
|
||
// es6-promise doesn't have allSettled by default | ||
Promise.allSettled = | ||
Promise.allSettled || | ||
(promises => | ||
Promise.all( | ||
promises.map(p => | ||
p | ||
.then(value => ({ | ||
status: 'fulfilled', | ||
value | ||
})) | ||
.catch(reason => ({ | ||
status: 'rejected', | ||
reason | ||
})) | ||
) | ||
)) | ||
|
||
polyfillGlobal('Promise', () => Promise) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters