Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PubSub<Events>

Type Parameters

Hierarchy

Index

Constructors

Properties

Methods

Constructors

  • new PubSub<Events>(): PubSub<Events>

Properties

events: {}

Type declaration

Methods

  • emit<Key>(event: number | Key, ...data: Parameters<Events[Key]>): void
  • 发布

    Type Parameters

    • Key extends string | number | symbol

    Parameters

    • event: number | Key

      事件名称

    • Rest ...data: Parameters<Events[Key]>

      载荷

    Returns void

  • off<Key>(event: Key, callback?: Events[keyof Events]): void
  • 销毁事件

    Type Parameters

    • Key extends string | number | symbol

    Parameters

    • event: Key

      事件名称

    • Optional callback: Events[keyof Events]

      事件方法

    Returns void

  • on<Key>(event: Key, callback: Events[keyof Events]): void
  • 订阅

    Type Parameters

    • Key extends string | number | symbol

    Parameters

    • event: Key

      事件名称

    • callback: Events[keyof Events]

      事件回调

    Returns void