essential_dart 2.0.0
essential_dart: ^2.0.0 copied to clipboard
Reusable building blocks, patterns, and services for Dart to improve efficiency and code quality.
2.0.0 #
Breaking Changes #
-
Task and TaskGroup now require generic type parameters for Label and Tags
Task<T>→Task<T, Label, Tags>TaskGroup<T>→TaskGroup<T, Label, Tags>- All subclasses, extensions, and methods updated to use generic parameters
labelfield type changed fromString?toLabel?tagsfield type changed fromSet<String>toTags?
Migration:
// Before final task = Task<int>.pending(label: 'fetch', tags: {'api'}); final group = TaskGroup<User>.uniform({...}); // After - Option 1: Use type aliases final task = SimpleTask<int>.pending(label: 'fetch', tags: {'api'}); final group = SimpleTaskGroup<User>.uniform({...}); // After - Option 2: Explicit types final task = Task<int, String?, Set<String>>.pending(label: 'fetch', tags: {'api'}); final group = TaskGroup<User, String?, Set<String>>.uniform({...});
New Features #
TaskGroup
- Added
TaskGroupAPI for managing collections of tasks with aggregate state.- Support for homogeneous (
TaskGroup.uniform) and heterogeneous (TaskGroup.mixed) groups. - Aggregate state derivation (Active, Completed, Failed, Idle, Partial).
- Batch operations (
runAll,mapTasks,retryFailed) for homogeneous groups. - Query extensions (
withLabel,withTags,byState,where). - State transition extensions (
toRunning,toPending,resetFailed). - Stream support via
watch. - Customizable Execution Strategy:
- Added
TaskGroupExecutionStrategyenum (parallel,sequential). runAllandwatchnow accept an optionalstrategyparameter (default:parallel).
- Added
- Support for homogeneous (
- Added
SimpleTaskGroup<T>type alias forTaskGroup<T, String?, Set<String>>
Task API Enhancements
- Added
SimpleTask<T>type alias forTask<T, String?, Set<String>> - Support for custom Label and Tags types (enums, custom classes, etc.) with full type safety.
- Added type-safe state getters (
.success,.failure,.pending, etc.) that throw detailedStateErrorif the state doesn't match. - Added
effectiveDatagetter to retrieve data from current or previous states. - Added caching support with
CachingStrategyenum (none, memoize, temporal).execute()method for cached task execution.invalidateCache()andrefresh()methods.- Cache persists across state transitions and defaults to 5 minutes for temporal strategy.
Utilities
- Retry: Added
Retryutility for retrying asynchronous operations with configurable strategies.- Strategies:
ConstantBackoffStrategy,LinearBackoffStrategy,ExponentialBackoffStrategy.
- Strategies:
- Interval: Added generic
Intervalclass for ranges of comparable values (int, double, DateTime).- Validation, set operations (
contains,overlaps,intersection,span), and utility extensions.
- Validation, set operations (
- Stream Transformers: Added powerful stream transformation utilities:
StringSplitter: Split string streams by separator.Debounce: Filter rapid-fire events.Throttle: Limit event rate.BufferCountandBufferTime: Batch processing.
1.1.0 #
- Added
TaskAPI for type-safe asynchronous operation state management - Added
TaskStateenum for explicit state representation - Added convenience transition methods:
toPending()- Transition to pending statetoRunning()- Transition to running statetoRefreshing()- Transition to refreshing state (allows null previousData)toRetrying()- Transition to retrying state (allows null previousData)toSuccess(T data)- Transition to success state with datatoFailure(Object error, {StackTrace? stackTrace})- Transition to failure state
- Added
stategetter to all Task classes - All transition methods automatically propagate label, tags, and initialData
- Updated state checking getters to use
TaskStateenum - Added
runandrunSyncmethods toTaskfor executing callbacks and returningTaskobjects. - Added
watchmethod toTaskfor creating streams that emitTaskstates. - Comprehensive test suite with 138 tests covering all functionality
1.0.0+1 #
- Updated package metadata and documentation.
1.0.0 #
- Initial release.
- Added
Memoizerutility for caching computation results.