feat(data-srouce): manager新增init事件

This commit is contained in:
roymondchen 2024-03-26 17:02:14 +08:00
parent 66e16452a8
commit 934398911d

View File

@ -71,7 +71,19 @@ class DataSourceManager extends EventEmitter {
this.addDataSource(config);
});
Promise.all(Array.from(this.dataSourceMap).map(async ([, ds]) => this.init(ds)));
const dataSourceList = Array.from(this.dataSourceMap);
Promise.allSettled<Record<string, any>>(dataSourceList.map(([, ds]) => this.init(ds))).then((values) => {
const data: DataSourceManagerData = {};
values.forEach((value, index) => {
if (value.status === 'fulfilled') {
const dsId = dataSourceList[index][0];
data[dsId] = this.data[dsId];
}
});
this.emit('init', data);
});
}
public async init(ds: DataSource) {