LevitReactiveTasksMixin mixin

A mixin for LevitController that combines task management with reactive state.

This mixin is ideal for controllers that drive UI needing to show loading states, progress bars, or error messages for asynchronous operations.

It exposes:

  • tasks: A reactive map of task IDs to their current LxStatus.
  • totalProgress: A computed value (0.0 to 1.0) representing overall progress.
Superclass constraints

Properties

autoCleanupDelay Duration?
Optional delay before automatically removing a completed task.
no setter
hashCode int
The hash code for this object.
no setterinherited
initialized bool
Whether onInit has been executed.
no setterinherited
isBusy LxComputed<bool>
A computed value indicating if any tasks are currently active.
latefinal
isClosed bool
Whether the controller is in the process of closing or is closed.
no setterinherited
isDisposed bool
Whether the controller has been disposed and closed.
no setterinherited
isInitialized bool
Whether the initialization phase is complete.
no setterinherited
maxConcurrentTasks int
The maximum number of concurrent tasks allowed.
no setter
maxTaskHistory int
The maximum number of completed tasks to keep in history.
no setter
onTaskError ↔ void Function(Object error, StackTrace? stackTrace)?
Optional global error handler for tasks in this controller.
getter/setter pair
ownerPath String
The full owner path within the monitoring system (scopeId:registrationKey).
no setterinherited
registrationKey String?
The registration key used to identify this instance in Levit.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scope LevitScope?
The LevitScope that currently owns this controller.
no setterinherited
taskCacheProvider LevitTaskCacheProvider
The cache provider used by this mixin.
no setter
taskProgress LxMap<String, double>
Reactive progress values (0.0 to 1.0) for active tasks.
final
tasks LxMap<String, LxStatus>
A reactive map of task IDs to their current status.
final
taskWeights LxMap<String, double>
Optional weights for individual tasks, used to calculate totalProgress.
final
totalProgress LxComputed<double>
A computed value representing the weighted average progress (0.0 to 1.0) of all active tasks.
latefinal

Methods

autoDispose<T>(T object) → T
Registers an object to be automatically cleaned up when this controller is closed.
inherited
cancelAllTasks() → void
Cancels all tasks.
cancelTask(String id) → void
Cancels a specific task.
clearCompleted() → void
Clears all completed (LxSuccess or LxIdle) tasks from the state map.
clearTask(String id) → void
Clears a task from the state map and cancels it if running.
didAttachToScope(LevitScope scope, {String? key}) → void
Invoked when the instance is successfully attached to its owning LevitScope.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onClose() → void
Callback invoked when the controller is being removed from Levit.
override
onInit() → void
Callback invoked after the controller is instantiated and registered.
override
runIsolateTask<T>(FutureOr<T> task(), {String? id, TaskPriority priority = TaskPriority.normal, int retries = 0, Duration? retryDelay, bool useExponentialBackoff = true, double weight = 1.0, void onError(Object error, StackTrace stackTrace)?, TaskCachePolicy<T>? cachePolicy, String? debugName}) Future<T?>
Executes a task in a separate Isolate using Isolate.run.
runTask<T>(Future<T> task(), {String? id, TaskPriority priority = TaskPriority.normal, int retries = 0, Duration? retryDelay, bool useExponentialBackoff = true, double weight = 1.0, void onError(Object error, StackTrace stackTrace)?, TaskCachePolicy<T>? cachePolicy}) Future<T?>
Executes a task and automatically tracks its status in tasks.
toString() String
A string representation of this object.
inherited
updateTaskProgress(String id, double value) → void
Manually update the progress of a specific task.

Operators

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