import { EventTarget } from "cc";

export enum EV_TYPE {
  USER_GOOD_REFRESH = 10001,
}

export default class EV {
  private static _ins: EV;
  public static get ins(): EV {
    if (!EV._ins) {
      EV._ins = new EV();
    }
    return EV._ins;
  }

  private e: EventTarget;
  constructor() {
    this.e = new EventTarget();
  }

  public on(event: EV_TYPE, callback: (...args: any[]) => void, target: any) {
    this.e.on(event, callback, target);
  }
  public off(event: EV_TYPE, callback: (...args: any[]) => void, target: any) {
    this.e.off(event, callback, target);
  }
  public emit(event: EV_TYPE, ...args: any[]) {
    this.e.emit(event, ...args);
  }
}
