Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/a2ui_core/lib/a2ui_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ export 'src/core/messages.dart';
export 'src/core/minimal_catalog.dart';
export 'src/core/surface_group_model.dart';
export 'src/core/surface_model.dart';
// Primitives.
export 'src/listenable/notifiers.dart';
export 'src/primitives/cancellation.dart';
export 'src/primitives/data_path.dart';
export 'src/primitives/errors.dart';
Expand Down
24 changes: 12 additions & 12 deletions packages/a2ui_core/lib/src/listenable/notifiers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ abstract class GenUiValueListenable<T> extends GenUiListenable {
///
/// This class should not be modified, because it is temporary and should be
/// replaced with dash-wide alternative.
mixin class GenUiChangeNotifier implements GenUiListenable {
mixin class ChangeNotifier implements GenUiListenable {
int _count = 0;
// The _listeners is intentionally set to a fixed-length _GrowableList instead
// of const [].
Expand All @@ -84,8 +84,8 @@ mixin class GenUiChangeNotifier implements GenUiListenable {
int _reentrantlyRemovedListeners = 0;
bool _debugDisposed = false;

/// Used by subclasses to assert that the [GenUiChangeNotifier] has not
/// yet been disposed.
/// Used by subclasses to assert that the [ChangeNotifier] has not yet been
/// disposed.
///
/// {@tool snippet}
/// The [debugAssertNotDisposed] function should only be called inside of an
Expand All @@ -103,7 +103,7 @@ mixin class GenUiChangeNotifier implements GenUiListenable {
// This is static and not an instance method because too many people try to
// implement ChangeNotifier instead of extending it (and so it is too breaking
// to add a method, especially for debug).
static bool debugAssertNotDisposed(GenUiChangeNotifier notifier) {
static bool debugAssertNotDisposed(ChangeNotifier notifier) {
assert(() {
if (notifier._debugDisposed) {
throw ListenableErrorReporting.createError(
Expand Down Expand Up @@ -150,7 +150,7 @@ mixin class GenUiChangeNotifier implements GenUiListenable {
/// (e.g. in response to a notification), it will still be called again. If,
/// on the other hand, it is removed as many times as it was registered, then
/// it will no longer be called. This odd behavior is the result of the
/// [GenUiChangeNotifier] not being able to determine which listener is being
/// [ChangeNotifier] not being able to determine which listener is being
/// removed, since they are identical, therefore it will conservatively still
/// call all the listeners when it knows that any are still registered.
///
Expand All @@ -165,7 +165,7 @@ mixin class GenUiChangeNotifier implements GenUiListenable {
/// the list of closures that are notified when the object changes.
@override
void addListener(VoidCallback listener) {
assert(GenUiChangeNotifier.debugAssertNotDisposed(this));
assert(ChangeNotifier.debugAssertNotDisposed(this));

if (_count == _listeners.length) {
if (_count == 0) {
Expand Down Expand Up @@ -269,7 +269,7 @@ mixin class GenUiChangeNotifier implements GenUiListenable {
/// listeners or not immediately before disposal.
@mustCallSuper
void dispose() {
assert(GenUiChangeNotifier.debugAssertNotDisposed(this));
assert(ChangeNotifier.debugAssertNotDisposed(this));
if (_notificationCallStackDepth > 0) {
throw ListenableErrorReporting.createError(
'The "dispose()" method on $this was called during the call to '
Expand Down Expand Up @@ -304,7 +304,7 @@ mixin class GenUiChangeNotifier implements GenUiListenable {
@visibleForTesting
@pragma('vm:notify-debugger-on-exception')
void notifyListeners() {
assert(GenUiChangeNotifier.debugAssertNotDisposed(this));
assert(ChangeNotifier.debugAssertNotDisposed(this));
if (_count == 0) {
return;
}
Expand Down Expand Up @@ -403,16 +403,16 @@ class _MergingListenable extends GenUiListenable {
}
}

/// A [GenUiChangeNotifier] that holds a single value.
/// A [ChangeNotifier] that holds a single value.
///
/// Dart replica of Flutter's [ValueNotifier](https://api.flutter.dev/flutter/foundation/ValueNotifier-class.html)
///
/// This class should not be modified, because it is temporary and should be
/// replaced with dash-wide alternative.
class GenUiValueNotifier<T> extends GenUiChangeNotifier
class ValueNotifier<T> extends ChangeNotifier
implements GenUiValueListenable<T> {
/// Creates a [GenUiChangeNotifier] that wraps this value.
GenUiValueNotifier(this._value);
/// Creates a [ChangeNotifier] that wraps this value.
ValueNotifier(this._value);

/// The current value stored in this notifier.
///
Expand Down
14 changes: 7 additions & 7 deletions packages/a2ui_core/test/listenable/listenable_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import 'package:a2ui_core/src/listenable/notifiers.dart';
import 'package:a2ui_core/src/listenable/primitives.dart';
import 'package:test/test.dart';

class TestNotifier extends GenUiChangeNotifier {
class TestNotifier extends ChangeNotifier {
void notify() {
notifyListeners();
}

bool get isListenedTo => hasListeners;
}

class HasListenersTester<T> extends GenUiValueNotifier<T> {
class HasListenersTester<T> extends ValueNotifier<T> {
HasListenersTester(super.value);
bool get testHasListeners => hasListeners;
}
Expand All @@ -27,7 +27,7 @@ class A {
}
}

class B extends A with GenUiChangeNotifier {
class B extends A with ChangeNotifier {
B();

@override
Expand All @@ -37,7 +37,7 @@ class B extends A with GenUiChangeNotifier {
}
}

class Counter with GenUiChangeNotifier {
class Counter with ChangeNotifier {
Counter();

int get value => _value;
Expand Down Expand Up @@ -378,7 +378,7 @@ void main() {
});

test('Value notifier', () {
final notifier = GenUiValueNotifier<double>(2.0);
final notifier = ValueNotifier<double>(2.0);

final log = <double>[];
void listener() {
Expand Down Expand Up @@ -513,11 +513,11 @@ void main() {

test('Calling debugAssertNotDisposed works as intended', () {
final testNotifier = TestNotifier();
expect(GenUiChangeNotifier.debugAssertNotDisposed(testNotifier), isTrue);
expect(ChangeNotifier.debugAssertNotDisposed(testNotifier), isTrue);
testNotifier.dispose();
ListenableError? error;
try {
GenUiChangeNotifier.debugAssertNotDisposed(testNotifier);
ChangeNotifier.debugAssertNotDisposed(testNotifier);
// ignore: avoid_catching_errors
} on ListenableError catch (e) {
error = e;
Expand Down
12 changes: 6 additions & 6 deletions packages/a2ui_core/test/listenable/smoke_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:a2ui_core/src/listenable/primitives.dart';
import 'package:test/test.dart';

// ignore: unused_element, tests that ValueNotifier can be implemented.
class _ValueNotifierImplementation<T> implements GenUiValueNotifier<T> {
class _ValueNotifierImplementation<T> implements ValueNotifier<T> {
@override
void addListener(VoidCallback listener) {}

Expand All @@ -31,12 +31,12 @@ class _ValueNotifierImplementation<T> implements GenUiValueNotifier<T> {
}

// ignore: unused_element, tests that ValueNotifier can be extended.
class _ValueNotifierExtension<T> extends GenUiValueNotifier<T> {
class _ValueNotifierExtension<T> extends ValueNotifier<T> {
_ValueNotifierExtension(super.value);
}

// ignore: unused_element, tests that ChangeNotifier can be implemented.
class _ChangeNotifierImplementation implements GenUiChangeNotifier {
class _ChangeNotifierImplementation implements ChangeNotifier {
@override
void addListener(VoidCallback listener) {}

Expand All @@ -54,11 +54,11 @@ class _ChangeNotifierImplementation implements GenUiChangeNotifier {
}

// ignore: unused_element, tests that ChangeNotifier can be extended.
class _ChangeNotifierExtention extends GenUiChangeNotifier {}
class _ChangeNotifierExtention extends ChangeNotifier {}

void main() {
test('ValueNotifier basic functionality is working', () {
final GenUiValueNotifier<int> notifier = GenUiValueNotifier(1);
final ValueNotifier<int> notifier = ValueNotifier(1);
addTearDown(notifier.dispose);
var count = 0;
notifier.addListener(() => count++);
Expand All @@ -73,7 +73,7 @@ void main() {
});

test('ChangeNotifier basic functionality is working', () {
final notifier = GenUiChangeNotifier();
final notifier = ChangeNotifier();
addTearDown(notifier.dispose);
var count = 0;
notifier.addListener(() => count++);
Expand Down
50 changes: 0 additions & 50 deletions packages/genui/lib/src/primitives/flutter_listenable.dart

This file was deleted.

1 change: 0 additions & 1 deletion packages/genui/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ environment:
resolution: workspace

dependencies:
a2ui_core: ^0.0.1-dev001
audioplayers: ^6.6.0
collection: ^1.19.1
flutter:
Expand Down
77 changes: 0 additions & 77 deletions packages/genui/test/primitives/flutter_listenable_test.dart

This file was deleted.

Loading