mirror of
https://github.com/immich-app/immich.git
synced 2026-10-01 13:57:10 +02:00
* chore: remove unused methods * Remove dead test group --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Adam Gastineau <adam@agg.im>
34 lines
761 B
Dart
34 lines
761 B
Dart
import 'dart:async';
|
|
|
|
class Event {
|
|
const Event();
|
|
}
|
|
|
|
class EventStream {
|
|
EventStream._();
|
|
|
|
static final EventStream shared = EventStream._();
|
|
|
|
final StreamController<Event> _controller = StreamController<Event>.broadcast();
|
|
|
|
void emit(Event event) {
|
|
_controller.add(event);
|
|
}
|
|
|
|
Stream<T> where<T extends Event>() {
|
|
if (T == Event) {
|
|
return _controller.stream as Stream<T>;
|
|
}
|
|
return _controller.stream.where((event) => event is T).cast<T>();
|
|
}
|
|
|
|
StreamSubscription<T> listen<T extends Event>(
|
|
void Function(T event)? onData, {
|
|
Function? onError,
|
|
void Function()? onDone,
|
|
bool? cancelOnError,
|
|
}) {
|
|
return where<T>().listen(onData, onError: onError, onDone: onDone, cancelOnError: cancelOnError);
|
|
}
|
|
}
|