feat(scene): add once event for scene

This commit is contained in:
yunji 2021-07-06 17:22:11 +08:00
parent a75f9511e3
commit f84fea5c0e
2 changed files with 7 additions and 0 deletions

View File

@ -9,6 +9,7 @@ export interface ISceneService {
fontFamily: string;
loadFont: boolean;
on(type: string, handle: (...args: any[]) => void): void;
once(type: string, handle: (...args: any[]) => void): void;
off(type: string, handle: (...args: any[]) => void): void;
removeAllListeners(event?: string): this;
init(config: IMapConfig & IRenderConfig): void;

View File

@ -266,6 +266,12 @@ class Scene
: this.sceneService.on(type, handle);
}
public once(type: string, handle: (...args: any[]) => void): void {
SceneEventList.indexOf(type) === -1
? this.mapService.once(type, handle)
: this.sceneService.once(type, handle);
}
public off(type: string, handle: (...args: any[]) => void): void {
SceneEventList.indexOf(type) === -1
? this.mapService.off(type, handle)