diff --git a/packages/core/src/services/scene/ISceneService.ts b/packages/core/src/services/scene/ISceneService.ts index 28b77cf473..42cea47212 100644 --- a/packages/core/src/services/scene/ISceneService.ts +++ b/packages/core/src/services/scene/ISceneService.ts @@ -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; diff --git a/packages/scene/src/index.ts b/packages/scene/src/index.ts index 6b5046edf8..b08a955be2 100644 --- a/packages/scene/src/index.ts +++ b/packages/scene/src/index.ts @@ -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)