diff --git a/lib/src/implements/notifier_impl.dart b/lib/src/implements/notifier_impl.dart index 6689096..3ad0162 100644 --- a/lib/src/implements/notifier_impl.dart +++ b/lib/src/implements/notifier_impl.dart @@ -45,6 +45,7 @@ abstract class StateNotifierImpl extends ChangeNotifier implements ValueListe if (kFlutterMemoryAllocationsEnabled) { ChangeNotifier.maybeDispatchObjectCreation(this); } + } @@ -71,6 +72,36 @@ abstract class StateNotifierImpl extends ChangeNotifier implements ValueListe _value = newState; } + @protected @override String toString() => '${describeIdentity(this)}($value)'; + + @protected + @override + void addListener(VoidCallback listener) { + super.addListener(listener); + } + + + @protected + @override + void removeListener(VoidCallback listener) => super.removeListener(listener); + + + @protected + @override + void dispose() => super.dispose(); + + + @immutable + @protected + @override + void notifyListeners() => super.notifyListeners(); + + + @immutable + @protected + @override + bool get hasListeners => super.hasListeners; + } diff --git a/lib/src/viewmodel/async_viewmodel_impl.dart b/lib/src/viewmodel/async_viewmodel_impl.dart index 06bc078..5cb22f3 100644 --- a/lib/src/viewmodel/async_viewmodel_impl.dart +++ b/lib/src/viewmodel/async_viewmodel_impl.dart @@ -1,16 +1,17 @@ import 'package:flutter/material.dart'; import 'package:reactive_notifier/src/handler/async_state.dart'; +import 'package:reactive_notifier/src/implements/notifier_impl.dart'; /// Base ViewModel implementation for handling asynchronous operations with state management. /// /// Provides a standardized way to handle loading, success, and error states for async data. -abstract class AsyncViewModelImpl extends ChangeNotifier { +abstract class AsyncViewModelImpl extends StateNotifierImpl { AsyncState _state = AsyncState.initial(); AsyncState get state => _state; Object? get error => _state.error; StackTrace? get stackTrace => _state.stackTrace; - AsyncViewModelImpl({bool loadOnInit = true}) { + AsyncViewModelImpl(super._value, {bool loadOnInit = true}) { if (loadOnInit) { reload(); }