control 1.0.0-dev.1
control: ^1.0.0-dev.1 copied to clipboard
Simple state management for Flutter with concurrency support.
1.0.0-dev.1 #
Features #
- ADDED: Generic
handle<T>()method - now supports return values- Example:
Future<User> fetchUser(String id) => handle<User>(() async { ... return user; }) - Type-safe return values from controller operations
- Works with all concurrency strategies (sequential, concurrent, droppable)
- Example:
Breaking Changes #
- REMOVED:
basemodifier fromController,StateController, and concurrency handler mixins- Controllers no longer require
finalorbasein user code - Provides more flexibility for inheritance patterns
- Controllers no longer require
- CHANGED:
Controller.handle()now has a default concurrent implementation- No longer abstract - controllers can be used without choosing a concurrency mixin
- Operations execute concurrently by default
- Provides zone for error catching, HandlerContext, observer notifications, and callbacks
- CHANGED: Concurrency handler mixins simplified to wrap
super.handle()withMutexSequentialControllerHandler- wraps handle with mutex for sequential executionDroppableControllerHandler- wraps handle with mutex and drops new operations if busyConcurrentControllerHandler- deprecated (base behavior is already concurrent)
- CHANGED:
Controller.handle()signature now includeserroranddonecallbacks- Before:
handle(handler, {name, meta}) - After:
handle<T>(handler, {error, done, name, meta})
- Before:
- CHANGED:
DroppableControllerHandlernow returnsnullwhen dropping operations- Handle method returns
Future<T?>to support nullable return values - Dropped operations return
nullinstead of throwing errors - This is the expected behavior for droppable operations
- Handle method returns
Added #
- ADDED: Base
handle()implementation inControllerclass- Concurrent execution by default
- Zone-based error catching (including unawaited futures)
- HandlerContext for debugging
- Observer notifications
- Error and done callbacks
- ADDED:
Mutexis now the core primitive for concurrency control- Can be used directly in controllers for custom concurrency patterns
- Sequential and droppable mixins built on top of Mutex
Improved #
- IMPROVED: Reduced code complexity
- Concurrency handler mixins reduced from ~300 lines to ~90 lines
- Removed
_ControllerEventQueueclass (no longer needed) - Simplified architecture easier to understand and maintain
- IMPROVED: More flexibility in concurrency control
- Use mixins for simple cases (sequential/droppable)
- Use Mutex directly for custom patterns
- Mix and match strategies in the same controller
Migration Guide #
See MIGRATION.md for detailed migration instructions from 0.x to 1.0.0.
Quick migration:
- Remove
basefrom your controller classes ConcurrentControllerHandlercan be removed (controllers are concurrent by default)SequentialControllerHandlerandDroppableControllerHandlerwork the same way- For custom concurrency, use
Mutexdirectly instead of creating custom mixins
0.2.0 #
- ADDED:
HandlerContextto handlers, available at zone and observer. - ADDED:
namegetter forController - ADDED:
void onHandler(HandlerContext context)toIControllerObserver - REMOVED:
donegetter fromController
0.1.0 #
- BREAKING CHANGE: Replace FutureOr with Future in handler
0.0.3-pre.1 #
- BREAKING CHANGE: Change
handlerapi and implementation
0.0.2 #
- Add example to README.md
- ControllerRegistry only for debug mode
0.0.1-pre.0 #
- Initial release