fix: polyfill Promise.allSettled

This commit is contained in:
guokai.jgk 2020-11-25 19:56:18 +08:00
parent 142aee55d2
commit 9ca4b3f92f
2 changed files with 7 additions and 1 deletions

View File

@ -19,10 +19,12 @@
"dependencies": {
"@ali/lowcode-datasource-types": "^1.0.21",
"@ali/lowcode-types": "^1.0.20",
"promise.allsettled": "^1.0.2",
"typescript": "^3.9.7"
},
"devDependencies": {
"@ava/babel": "^1.0.1",
"@types/promise.allsettled": "^1.0.3",
"@types/sinon": "^9.0.5",
"ava": "3.11.1",
"get-port": "^5.1.1",

View File

@ -1,4 +1,8 @@
import { DataSourceMap, RuntimeDataSource, RuntimeDataSourceConfig } from '@ali/lowcode-types';
import allSettled from 'promise.allsettled';
// 兼容低版本的浏览器
const promiseSettled = typeof Promise.allSettled === 'function' ? Promise.allSettled : allSettled;
export const reloadDataSourceFactory = (
dataSource: RuntimeDataSource,
@ -56,7 +60,7 @@ export const reloadDataSourceFactory = (
}
}
await Promise.allSettled(allAsyncLoadings);
await promiseSettled(allAsyncLoadings);
// 所有的初始化请求都结束之后,调用钩子函数