mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 19:38:05 +00:00
fix(material): when the assets exist, use onChangeAssets api, the callback is called immediately
This commit is contained in:
parent
0eeee1feee
commit
c458b1b2ec
@ -222,6 +222,16 @@ export class Editor extends EventEmitter implements IEditor {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onChange<T = undefined, KeyOrType extends IPublicTypeEditorValueKey = any>(
|
||||||
|
keyOrType: KeyOrType,
|
||||||
|
fn: (data: IPublicTypeEditorGetResult<T, KeyOrType>) => void,
|
||||||
|
): () => void {
|
||||||
|
this.setWait(keyOrType, fn);
|
||||||
|
return () => {
|
||||||
|
this.delWait(keyOrType, fn);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
register(data: any, key?: IPublicTypeEditorValueKey): void {
|
register(data: any, key?: IPublicTypeEditorValueKey): void {
|
||||||
this.context.set(key || data, data);
|
this.context.set(key || data, data);
|
||||||
this.notifyGot(key || data);
|
this.notifyGot(key || data);
|
||||||
|
|||||||
@ -181,7 +181,7 @@ export class Material implements IPublicApiMaterial {
|
|||||||
onChangeAssets(fn: () => void): IPublicTypeDisposable {
|
onChangeAssets(fn: () => void): IPublicTypeDisposable {
|
||||||
const dispose = [
|
const dispose = [
|
||||||
// 设置 assets,经过 setAssets 赋值
|
// 设置 assets,经过 setAssets 赋值
|
||||||
this[editorSymbol].onGot('assets', fn),
|
this[editorSymbol].onChange('assets', fn),
|
||||||
// 增量设置 assets,经过 loadIncrementalAssets 赋值
|
// 增量设置 assets,经过 loadIncrementalAssets 赋值
|
||||||
this[editorSymbol].eventBus.on('designer.incrementalAssetsReady', fn),
|
this[editorSymbol].eventBus.on('designer.incrementalAssetsReady', fn),
|
||||||
];
|
];
|
||||||
|
|||||||
@ -15,13 +15,27 @@ export interface IPublicModelEditor extends StrictEventEmitter<EventEmitter, Glo
|
|||||||
|
|
||||||
set: (key: IPublicTypeEditorValueKey, data: any) => void | Promise<void>;
|
set: (key: IPublicTypeEditorValueKey, data: any) => void | Promise<void>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 keyOrType 一次
|
||||||
|
*/
|
||||||
onceGot: <T = undefined, KeyOrType extends IPublicTypeEditorValueKey = any>(keyOrType: KeyOrType) => Promise<IPublicTypeEditorGetResult<T, KeyOrType>>;
|
onceGot: <T = undefined, KeyOrType extends IPublicTypeEditorValueKey = any>(keyOrType: KeyOrType) => Promise<IPublicTypeEditorGetResult<T, KeyOrType>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 keyOrType 多次
|
||||||
|
*/
|
||||||
onGot: <T = undefined, KeyOrType extends IPublicTypeEditorValueKey = any>(
|
onGot: <T = undefined, KeyOrType extends IPublicTypeEditorValueKey = any>(
|
||||||
keyOrType: KeyOrType,
|
keyOrType: KeyOrType,
|
||||||
fn: (data: IPublicTypeEditorGetResult<T, KeyOrType>) => void
|
fn: (data: IPublicTypeEditorGetResult<T, KeyOrType>) => void
|
||||||
) => () => void;
|
) => () => void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听 keyOrType 变化
|
||||||
|
*/
|
||||||
|
onChange: <T = undefined, KeyOrType extends IPublicTypeEditorValueKey = any>(
|
||||||
|
keyOrType: KeyOrType,
|
||||||
|
fn: (data: IPublicTypeEditorGetResult<T, KeyOrType>) => void
|
||||||
|
) => () => void;
|
||||||
|
|
||||||
register: (data: any, key?: IPublicTypeEditorValueKey, options?: IPublicTypeEditorRegisterOptions) => void;
|
register: (data: any, key?: IPublicTypeEditorValueKey, options?: IPublicTypeEditorRegisterOptions) => void;
|
||||||
|
|
||||||
get eventBus(): IPublicApiEvent;
|
get eventBus(): IPublicApiEvent;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user