ZenEffect<T> class
A reactive effect that manages async operations with loading, data, and error states Uses the Zen reactive system for consistent API and optimal performance
- Available extensions
Constructors
- ZenEffect.new({required String name})
Properties
-
data
→ Rx<
T?> -
The current data value - using Rx for consistent reactive behavior
no setter
- dataWasSet → RxBool
-
Whether data has been set at least once - using RxBool for consistent reactive behavior
no setter
-
error
→ Rx<
Object?> -
The current error, if any - using Rx for consistent reactive behavior
no setter
- hasData → bool
-
Whether the effect has data (including null data that was explicitly set)
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDisposed → bool
-
Whether this effect has been disposed
no setter
- isLoading → RxBool
-
Whether the effect is currently loading - using RxBool for consistent reactive behavior
no setter
- name → String
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clearData(
) → void - Clear only the data
-
clearError(
) → void - Clear only the error state
-
dispose(
) → void - Dispose the effect and clean up resources
-
loading(
) → void - Set the loading state
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void - Reset the effect to initial state
-
run(
Future< T> operation()) → Future<T?> - Run an async operation with automatic state management Returns null if the effect is disposed during execution
-
setError(
Object error) → void - Set error state
-
success(
T? data) → void - Set successful data
-
toString(
) → String -
A string representation of this object.
override
-
watch(
ZenController controller, {void onData(T?)?, void onLoading(bool)?, void onError(Object?)?, String? name}) → void Function() -
Available on ZenEffect<
Unified watch method for all effect aspects using ZenWorkers directlyT> , provided by the ZenEffectWatch extension -
watchData(
ZenController controller, void callback(T?), {String? name}) → void Function() -
Available on ZenEffect<
Convenience method for watching only data changesT> , provided by the ZenEffectWatch extension -
watchError(
ZenController controller, void callback(Object?), {String? name}) → void Function() -
Available on ZenEffect<
Convenience method for watching only error stateT> , provided by the ZenEffectWatch extension -
watchLoading(
ZenController controller, void callback(bool), {String? name}) → void Function() -
Available on ZenEffect<
Convenience method for watching only loading stateT> , provided by the ZenEffectWatch extension
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited