Skip to content

Commit

Permalink
feat(data-srouce): manager新增init事件
Browse files Browse the repository at this point in the history
  • Loading branch information
roymondchen committed Mar 26, 2024
1 parent 66e1645 commit 9343989
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/data-source/src/DataSourceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9343989

Please sign in to comment.