神岛 API 文档 - ArenaPro版
    Preparing search index...

    Type Alias GameEventChannel<EventType>

    GameEventChannel: (handler: (event: EventType) => void) => GameEventHandlerToken

    使用 EventChannel 可以订阅来自某些对象的事件。

    事件通道接受一个事件处理程序作为输入,并返回一个可以用于取消处理程序的令牌。

    示例:

    const token = world.onTick(() => console.log("tick !"));
    setTimeout(() => {
    console.log('取消 tick 处理程序');
    token.cancel();
    // 不再记录 tick 事件
    }, 1000);

    Type Parameters

    • EventType

    Type declaration

    EventType 通道发出的事件类型。