import 'dart:async';

class EventBus {
  final StreamController<dynamic> _controller = StreamController.broadcast();

  Stream<T> on<T>() {
    return _controller.stream.where((event) => event is T).cast<T>();
  }

  void emit(dynamic event) {
    _controller.add(event);
  }

  void dispose() {
    _controller.close();
  }
}

// 全局事件总线实例
final eventBus = EventBus();

// Token 过期事件
class TokenExpiredEvent {}

// 退出登录事件
class LogoutEvent {}
