mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-09-07 02:19:47 +08:00
fix(data-source): 兼容Promise.allSettled
This commit is contained in:
parent
5873842260
commit
7ee7f53938
@ -74,6 +74,8 @@ class DataSourceManager extends EventEmitter {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const dataSourceList = Array.from(this.dataSourceMap);
|
const dataSourceList = Array.from(this.dataSourceMap);
|
||||||
|
|
||||||
|
if (typeof Promise.allSettled === 'function') {
|
||||||
Promise.allSettled<Record<string, any>>(dataSourceList.map(([, ds]) => this.init(ds))).then((values) => {
|
Promise.allSettled<Record<string, any>>(dataSourceList.map(([, ds]) => this.init(ds))).then((values) => {
|
||||||
const data: DataSourceManagerData = {};
|
const data: DataSourceManagerData = {};
|
||||||
const errors: Record<string, Error> = {};
|
const errors: Record<string, Error> = {};
|
||||||
@ -89,6 +91,15 @@ class DataSourceManager extends EventEmitter {
|
|||||||
|
|
||||||
this.emit('init', data, errors);
|
this.emit('init', data, errors);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
Promise.all<Record<string, any>>(dataSourceList.map(([, ds]) => this.init(ds)))
|
||||||
|
.then(() => {
|
||||||
|
this.emit('init', this.data);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.emit('init', this.data);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async init(ds: DataSource) {
|
public async init(ds: DataSource) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user