Files
bowlingManager/mobile/lib/services/event_bus.dart
T
2025-08-09 03:09:17 +09:00

34 lines
662 B
Dart

import 'dart:async';
class EventBus {
static final EventBus _instance = EventBus._internal();
factory EventBus() => _instance;
EventBus._internal();
final _streamController = StreamController.broadcast();
Stream get stream => _streamController.stream;
void fire(dynamic event) {
_streamController.add(event);
}
// 특정 타입의 이벤트를 구독하는 메서드
Stream<T> on<T>() {
return stream.where((event) => event is T).cast<T>();
}
void dispose() {
_streamController.close();
}
}
// 이벤트 클래스들
class ClubChangedEvent {
final String clubId;
ClubChangedEvent(this.clubId);
}