Skip to content

Commit

Permalink
refactor: 重构 on 和 emit 类型
Browse files Browse the repository at this point in the history
  • Loading branch information
wjgogogo committed Mar 25, 2024
1 parent 4d0dfc9 commit 4c38a5d
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions packages/s2-core/src/sheet-type/spread-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,6 @@ export abstract class SpreadSheet extends EE {
*/
private destroyed = false;

// @ts-ignore
private untypedOn = this.on;

// @ts-ignore
private untypedEmit = this.emit;

public on = <K extends keyof EmitterType>(
event: K,
listener: EmitterType[K],
): this => this.untypedOn(event, listener);

public emit = <K extends keyof EmitterType>(
event: K,
...args: Parameters<EmitterType[K]>
): boolean => this.untypedEmit(event, ...args);

protected abstract bindEvents(): void;

public abstract getDataSet(): BaseDataSet;
Expand Down Expand Up @@ -597,6 +581,20 @@ export abstract class SpreadSheet extends EE {
this.container.resize(width, height);
}

public override on<K extends keyof EmitterType>(
event: K,
listener: EmitterType[K],
): this {
return super.on(event, listener);
}

public override emit<K extends keyof EmitterType>(
event: K,
...args: Parameters<EmitterType[K]>
): void {
super.emit(event, ...args);
}

/**
* 获取 G Canvas 实例
* @see https://g.antv.antgroup.com/api/renderer/canvas
Expand Down

0 comments on commit 4c38a5d

Please sign in to comment.