SignalAction<T> class

Action - Encapsulates async mutations with state tracking.

Actions provide a structured way to handle async operations with loading state and error handling.

Basic Usage

final loginAction = SignalAction<User>(
  name: 'login',
  execute: () async {
    return await authService.login();
  },
  onError: (error, stack) => print('Login failed: $error'),
);

// In UI:
if (loginAction.isExecuting.value) {
  return CircularProgressIndicator();
}

ElevatedButton(
  onPressed: () => loginAction.run(),
  child: Text('Login'),
)

Constructors

SignalAction({required String name, required Future<T> execute(), void after(T result)?, void onError(Object error, StackTrace stackTrace)?})

Properties

after → void Function(T result)?
final
error Signal<Object?>
final
execute Future<T> Function()
final
hashCode int
The hash code for this object.
no setterinherited
isExecuting Signal<bool>
final
name String
final
onError → void Function(Object error, StackTrace stackTrace)?
final
result Signal<T?>
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Dispose all signals.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run() Future<T?>
Run the action.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited