Remove: deleting old test helper files
This commit is contained in:
parent
c01e96ddc9
commit
6c8ca004ba
4 changed files with 0 additions and 142 deletions
|
@ -1,17 +0,0 @@
|
||||||
abstract class AppEvent {
|
|
||||||
String get timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
class EmptyEvent extends AppEvent {
|
|
||||||
@override
|
|
||||||
String get timestamp => DateTime.now().toIso8601String();
|
|
||||||
}
|
|
||||||
|
|
||||||
class EventCompletionEvent extends AppEvent {
|
|
||||||
final AppEvent completedEvent;
|
|
||||||
|
|
||||||
EventCompletionEvent(this.completedEvent);
|
|
||||||
|
|
||||||
@override
|
|
||||||
String get timestamp => DateTime.now().toIso8601String();
|
|
||||||
}
|
|
|
@ -1,97 +0,0 @@
|
||||||
import 'dart:async';
|
|
||||||
import 'package:angel3_event_bus/event_bus.dart';
|
|
||||||
import 'package:angel3_reactivex/subjects.dart';
|
|
||||||
import 'package:logger/logger.dart';
|
|
||||||
import 'app_event.dart' hide AppEvent, EmptyEvent;
|
|
||||||
import 'history_entry.dart' hide EventBusHistoryEntry;
|
|
||||||
import 'subscription.dart' hide Subscription, Responder;
|
|
||||||
|
|
||||||
class DummyEventBus implements IEventBus {
|
|
||||||
final _logger = Logger();
|
|
||||||
final _lastEventSubject = BehaviorSubject<AppEvent>();
|
|
||||||
final _inProgress = BehaviorSubject<List<AppEvent>>.seeded([]);
|
|
||||||
final List<EventBusHistoryEntry> _history = [];
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool get isBusy => false;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Stream<bool> get isBusy$ => Stream.value(false);
|
|
||||||
|
|
||||||
@override
|
|
||||||
AppEvent? get last => null;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Stream<AppEvent?> get last$ => _lastEventSubject.distinct();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Stream<List<AppEvent>> get inProgress$ => _inProgress.stream;
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<EventBusHistoryEntry> get history => List.unmodifiable(_history);
|
|
||||||
|
|
||||||
@override
|
|
||||||
void fire(AppEvent event) {
|
|
||||||
_lastEventSubject.add(event);
|
|
||||||
_logger.d(' ⚡️ [${event.timestamp}] $event');
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void watch(AppEvent event) {
|
|
||||||
fire(event);
|
|
||||||
_inProgress.add([..._inProgress.value, event]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void complete(AppEvent event, {AppEvent? nextEvent}) {
|
|
||||||
final newArr = _inProgress.value.toList()..removeWhere((e) => e == event);
|
|
||||||
_inProgress.add(newArr);
|
|
||||||
if (nextEvent != null) {
|
|
||||||
fire(nextEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool isInProgress<T>() {
|
|
||||||
return _inProgress.value.whereType<T>().isNotEmpty;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Stream<T> on<T extends AppEvent>() {
|
|
||||||
if (T == dynamic) {
|
|
||||||
return _lastEventSubject.stream as Stream<T>;
|
|
||||||
} else {
|
|
||||||
return _lastEventSubject.stream.where((event) => event is T).cast<T>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Subscription respond<T>(Responder<T> responder) {
|
|
||||||
return Subscription(_lastEventSubject).respond<T>(responder);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Stream<bool> whileInProgress<T extends AppEvent>() {
|
|
||||||
return _inProgress.map((events) {
|
|
||||||
return events.whereType<T>().isNotEmpty;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void clearHistory() {
|
|
||||||
_history.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void reset() {
|
|
||||||
clearHistory();
|
|
||||||
_inProgress.add([]);
|
|
||||||
_lastEventSubject.add(EmptyEvent());
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_inProgress.close();
|
|
||||||
_lastEventSubject.close();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
import 'app_event.dart';
|
|
||||||
|
|
||||||
class EventBusHistoryEntry {
|
|
||||||
final AppEvent event;
|
|
||||||
final String timestamp;
|
|
||||||
|
|
||||||
EventBusHistoryEntry(this.event, this.timestamp);
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
import 'package:angel3_reactivex/subjects.dart';
|
|
||||||
import 'app_event.dart';
|
|
||||||
|
|
||||||
typedef Responder<T> = void Function(T event);
|
|
||||||
|
|
||||||
class Subscription {
|
|
||||||
final BehaviorSubject<AppEvent> _subject;
|
|
||||||
|
|
||||||
Subscription(this._subject);
|
|
||||||
|
|
||||||
void respond<T>(Responder<T> responder) {
|
|
||||||
_subject.stream.where((event) => event is T).listen((event) {
|
|
||||||
responder(event as T);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void dispose() {
|
|
||||||
// Implement disposal logic if needed
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue