From f66ec52a49ef5a85054060dea1f8d1579915cfbc Mon Sep 17 00:00:00 2001 From: beeth0ven Date: Sat, 4 Jun 2022 17:12:08 +0800 Subject: [PATCH] add `Subject` interface --- lib/src/observables/observables.dart | 1 + lib/src/observables/subjects/subject.dart | 6 ++++ test/observables/observables_test.dart | 2 ++ test/observables/subjects/subject_test.dart | 32 +++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 lib/src/observables/subjects/subject.dart create mode 100644 test/observables/subjects/subject_test.dart diff --git a/lib/src/observables/observables.dart b/lib/src/observables/observables.dart index 9a260b5..5dfabde 100644 --- a/lib/src/observables/observables.dart +++ b/lib/src/observables/observables.dart @@ -3,3 +3,4 @@ export 'package:disposal/disposal.dart' show Disposable; export 'observables/observable.dart'; export 'observables/proxy_observable.dart'; export 'observers/observer.dart'; +export 'subjects/subject.dart'; diff --git a/lib/src/observables/subjects/subject.dart b/lib/src/observables/subjects/subject.dart new file mode 100644 index 0000000..4a7010e --- /dev/null +++ b/lib/src/observables/subjects/subject.dart @@ -0,0 +1,6 @@ + +import 'package:disposal/disposal.dart'; +import '../observables/observable.dart'; +import '../observers/observer.dart'; + +abstract class Subject implements Observable, Observer, Disposable {} diff --git a/test/observables/observables_test.dart b/test/observables/observables_test.dart index 8106379..a4bd9d0 100644 --- a/test/observables/observables_test.dart +++ b/test/observables/observables_test.dart @@ -9,6 +9,7 @@ import 'observables/proxy_observable_test.dart' as proxy_observable_test; import 'observables/skip_observable_test.dart' as skip_observable_test; import 'observables/where_observable_test.dart' as where_observable_test; import 'observers/observer_test.dart' as observer_test; +import 'subjects/subject_test.dart' as subject_test; void main() { @@ -22,4 +23,5 @@ void main() { skip_observable_test.main(); where_observable_test.main(); observer_test.main(); + subject_test.main(); } diff --git a/test/observables/subjects/subject_test.dart b/test/observables/subjects/subject_test.dart new file mode 100644 index 0000000..9ebb8cf --- /dev/null +++ b/test/observables/subjects/subject_test.dart @@ -0,0 +1,32 @@ + +import 'package:test/test.dart'; +import 'package:scopes/scopes.dart'; + +void main() { + + test('subject is observable, observer and disposable', () { + final subject = _MockSubject(); + expect(subject, isA>()); + expect(subject, isA>()); + expect(subject, isA()); + }); + +} + +class _MockSubject implements Subject { + + @override + Disposable observe(OnData onData) { + throw UnimplementedError(); + } + + @override + void onData(T data) { + throw UnimplementedError(); + } + + @override + void dispose() { + throw UnimplementedError(); + } +}