feat: change the order of load workspaces

This commit is contained in:
MingLiang Wang
2023-01-10 20:11:46 +08:00
parent b4571539ac
commit 104693916f
4 changed files with 13 additions and 10 deletions

View File

@@ -46,6 +46,10 @@ export class DataCenter {
dc.registerProvider(new LocalProvider(getInitParams()));
dc.registerProvider(new AffineProvider(getInitParams()));
for (const provider of dc.providerMap.values()) {
await provider.loadWorkspaces();
}
return dc;
}
@@ -181,8 +185,14 @@ export class DataCenter {
* @param {Function} callback callback function
*/
public async onWorkspacesChange(
callback: (workspaces: WorkspaceUnitCollectionChangeEvent) => void
callback: (workspaces: WorkspaceUnitCollectionChangeEvent) => void,
{ immediate = true }: { immediate?: boolean }
) {
if (immediate) {
callback({
added: this._workspaceUnitCollection.workspaces,
});
}
this._workspaceUnitCollection.on('change', callback);
}