fix: designer/loadIncrementalAssets await Sequential (#841)

* fix: designer/loadIncrementalAssets await Sequential

* feat: change editor set support Promise
This commit is contained in:
guowenfh 2022-07-21 17:24:47 +08:00 committed by GitHub
parent 70e7c1c2e8
commit 8232424697
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -403,7 +403,8 @@ export class Designer {
// 合并assets
let assets = this.editor.get('assets');
let newAssets = megreAssets(assets, incrementalAssets);
this.editor.set('assets', newAssets);
// 对于 assets 存在需要二次网络下载的过程,必须 await 等待结束之后,再进行事件触发
await this.editor.set('assets', newAssets);
}
// TODO: 因为涉及修改 prototype.view之后在 renderer 里修改了 vc 的 view 获取逻辑后,可删除
this.refreshComponentMetasMap();

View File

@ -76,10 +76,9 @@ export class Editor extends (EventEmitter as any) implements IEditor {
return this.context.has(keyOrType);
}
set(key: KeyType, data: any): void {
set(key: KeyType, data: any): void | Promise<void> {
if (key === 'assets') {
this.setAssets(data);
return;
return this.setAssets(data);
}
// store the data to engineConfig while invoking editor.set()
if (!keyBlacklist.includes(key as string)) {

View File

@ -40,7 +40,7 @@ export interface IEditor extends StrictEventEmitter<EventEmitter, GlobalEvent.Ev
has: (keyOrType: KeyType) => boolean;
set: (key: KeyType, data: any) => void;
set: (key: KeyType, data: any) => void | Promise<void>;
onceGot: <T = undefined, KeyOrType extends KeyType = any>
(keyOrType: KeyOrType) => Promise<GetReturnType<T, KeyOrType>>;