unsubscribe static method

void unsubscribe(
  1. SubscriptionToken token
)

取消由 subscribe 注册的事件监听。

@param token subscribe 返回的订阅令牌

Implementation

static void unsubscribe(SubscriptionToken token) {
  final inst = _shared;
  if (inst == null) return;
  final list = inst._eventHandlers[token.eventName];
  if (list == null) return;
  list.remove(token.handler);
  if (list.isEmpty) {
    inst._eventHandlers.remove(token.eventName);
  }
}