feat(data-source): manager init 事件增加error数据

This commit is contained in:
roymondchen 2024-05-08 19:26:53 +08:00
parent 9034cef0d2
commit 708d3db4bb

View File

@ -69,15 +69,18 @@ class DataSourceManager extends EventEmitter {
const dataSourceList = Array.from(this.dataSourceMap);
Promise.allSettled<Record<string, any>>(dataSourceList.map(([, ds]) => this.init(ds))).then((values) => {
const data: DataSourceManagerData = {};
const errors: Record<string, Error> = {};
values.forEach((value, index) => {
const dsId = dataSourceList[index][0];
if (value.status === 'fulfilled') {
const dsId = dataSourceList[index][0];
data[dsId] = this.data[dsId];
} else if (value.status === 'rejected') {
errors[dsId] = value.reason;
}
});
this.emit('init', data);
this.emit('init', data, errors);
});
}