commandy library
Commandy A package that provides an easy-to-use pattern for executing and listening to asynchronous commands, with result handling and optional UI integration.
See README.md for detailed usage instructions.
Classes
-
BaseCommand<
T> - An interface that represents a command exposing its latest Result.
-
Command<
T, Params> - A class that facilitates interaction with a ViewModel or UseCase. It encapsulates an asynchronous action and exposes its state and result.
- CommandListener
- A widget that listens to multiple commands and executes callbacks when their results change.
- CommandListenerConfig
- Configuration class for a command listener. Contains the command to listen to and the corresponding listener callback.
- Failure
- A generic failure representation containing error details.
-
FailureResult<
T> - A subclass of Result that represents a failed operation.
- NoParams
- A class that represents the absence of parameters for a command.
-
Result<
T> - A sealed class that represents the result of an operation, which can either be a Success containing data, or a FailureResult containing a Failure.
-
StreamCommand<
T, Params> - A class that facilitates interaction with a StreamUseCase. It encapsulates a stream action, exposes its current data and error states, and ensures proper subscription management.
-
Success<
T> - A subclass of Result that represents a successful operation.
-
ViewModelSelector<
T extends ChangeNotifier, R> - A widget that listens to changes in a ChangeNotifier-based ViewModel and rebuilds only when a specific property, selected by the selector, changes.
Typedefs
-
ViewModelPropertySelector<
T, R> = R Function(T viewModel) -
A function that extracts a specific property
R
from a ViewModel.