oref 2.0.2
oref: ^2.0.2 copied to clipboard
A reactive state management library for Flutter that adds magic to any Widget with signals, computed values, and effects powered by alien_signals.
2.1.0 #
Status: Unreleased
💥 BREAKING CHANGES #
Remove GlobalSignals.* APIs
GlobalSignals.create(value)->signal(null, value)GlobalSignals.computed(getter)->computed(null, getter)GlobalSignals.effect(callback)->effect(null, callback)GlobalSignals.effectScope(callback)->effectScope(null, callback)
2.0.2 #
2.0.1 #
- Fix
ReactiveList.addimplementation for non-nullable elements
2.0.0 #
💥 BREAKING CHANGES #
This is a complete rewrite of Oref with breaking changes to most APIs. The new version provides better performance, cleaner APIs, and improved developer experience.
API Changes
useSignal→signal: ReplaceuseSignal(context, value)withsignal(context, value)useComputed→computed: ReplaceuseComputed(context, computation)withcomputed(context, computation)useEffect→effect: ReplaceuseEffect(context, callback)witheffect(context, callback)useEffectScope→effectScope: ReplaceuseEffectScope(context)witheffectScope(context)- Widget Effect Hooks:
getWidgetEffectandgetWidgetScoperenamed touseWidgetEffectanduseWidgetScope - Memoization:
resetMemoizedrenamed toresetMemoizedForfor clarity - Reactive Access: Direct signal calls now supported in widgets (e.g.,
Text('${count()}')), replacing the need forSignalBuilderin many cases
Removed Features
- Removed entire old signal system implementation (848 lines deleted)
- Removed global async computed APIs (
createGlobalAsyncComputed,useAsyncComputed) - Removed legacy primitive operators
- Removed old async utilities and global signal management
✨ NEW FEATURES #
Reactive Collections
ReactiveList<T>: Reactive wrapper for List operations with automatic dependency trackingReactiveMap<K, V>: Reactive wrapper for Map operations with automatic dependency trackingReactiveSet<T>: Reactive wrapper for Set operations with automatic dependency tracking- Factory Constructors: Support for widget-scoped reactive collections via
.scoped()constructors - Global Collections: Support for global reactive collections via default constructors
Enhanced Widget Integration
SignalBuilder: New widget for explicit reactive UI updatesSignalBuildContextExtension: Addscontext.watch()method for reactive value access- Direct Signal Access: Signals can now be called directly in widget build methods
- Improved Widget Effects: Better automatic rebuild triggering when signal dependencies change
New Utilities
GlobalSignals: Utility class for managing global signal instancesbatch()anduntrack(): Export utility functions from alien_signals for advanced use cases- Enhanced Ref System: Improved
Ref,StateRef, andWidgetRefutilities moved to dedicated utils module
🔧 IMPROVEMENTS #
Performance
- Built on alien_signals v0.5.3 for optimal performance
- Removed global mutable state in computed values
- Improved memoization with better scope handling and lifecycle management
- Simplified effect and scope management for reduced overhead
Developer Experience
- Better Documentation: Comprehensive inline documentation with examples for all APIs
- Cleaner API Surface: More intuitive function names following React hooks conventions
- Simplified Widget Integration: Signals can be used directly in widget build methods without complex setup
- Better Error Handling: Improved assertions and error messages for memoization and widget context usage
- Organized Code Structure: Reorganized exports and moved utilities to separate directories for better maintainability
Architecture
- Complete Rewrite: Built from ground up with lessons learned from v1.x
- Widget Effect System: New widget effect pattern for consistent scope management
- Improved Memoization: Better widget-scoped memoization with proper lifecycle management
- Modular Design: Clear separation between core primitives, reactive collections, utilities, and widgets
- Type Safety: Enhanced type safety throughout the API surface
🔄 MIGRATION GUIDE #
Basic Signal Usage
// v1.x
final count = useSignal(context, 0);
// v2.0
final count = signal(context, 0);
Computed Values
// v1.x
final doubled = useComputed(context, () => count.value * 2);
// v2.0
final doubled = computed(context, () => count() * 2);
Effects
// v1.x
useEffect(context, () {
print('Count: ${count.value}');
});
// v2.0
effect(context, () {
print('Count: ${count()}');
});
Widget Reactivity
// v1.x - Required SignalBuilder or manual tracking
SignalBuilder(
signal: count,
builder: (context, value, _) => Text('Count: $value'),
)
// v2.0 - Direct access supported
Text('Count: ${count()}')
// or explicit watching
Text('Count: ${context.watch(() => count())}')
// or SignalBuilder
SignalBUilder(
getter: count,
builder: (context, value) => Text('Count: $value'),
);
Reactive Collections
// v2.0 - New feature
final items = ReactiveList<String>(['a', 'b', 'c']);
final itemsScoped = ReactiveList.scoped(context, ['a', 'b', 'c']);
🗂️ PACKAGE STRUCTURE #
The new version features a well-organized package structure:
- Core:
signal,computed,effect,effectScope,useMemoized, widget effects - Reactive:
Reactivemixin,ReactiveList,ReactiveMap,ReactiveSet - Utils:
batch,untrack,GlobalSignals,Refutilities,SignalBuildContext - Widgets:
SignalBuilderfor explicit reactive UI
⚡ PERFORMANCE #
- Upgraded to alien_signals v0.5.3 for optimal performance
- Removed global state management overhead
- Streamlined memoization and effect tracking
- More efficient widget rebuild patterns
📦 DEPENDENCIES #
- alien_signals: ^0.5.3 (upgraded from ^0.4.2)
- Flutter SDK: ^3.8.1 (maintained)
1.1.3 #
- pref: Refactor binding system to use LinkedBindingNode hierarchy
1.1.2 #
- Not returning use* hooks as expected
1.1.1 #
- fix: Nested hooks cause context binding to be reset
1.1.0 #
- refactor: refactor core code to make it easier to maintain and less redundant
- refactor: Remove
createGlobalAsyncComputedanduseAsyncComputed - feat:
createGlobalSignalsupports automatic trigger of Widget - feat:
createGlobalComputedsupports automatic trigger of Widget - feat: Added
createGlobalAsyncResultanduseAsyncResultto replacecreateGlobalAsyncComputed/useAsyncComputed
1.0.0 #
Added #
- Initial release of Oref - A reactive state management library for Flutter
- Core reactive primitives:
useSignal- Create reactive signals with automatic dependency trackinguseComputed- Create computed values that update when dependencies changeuseEffect- Create side effects that run when dependencies changeuseEffectScope- Create effect scopes for managing multiple effectsref- Convert non-reactive Widget parameters to reactive signals
- Global APIs for use outside of widgets:
createGlobalSignal- Create global signalscreateGlobalComputed- Create global computed valuescreateGlobalEffect- Create global effectscreateGlobalEffectScope- Create global effect scopescreateGlobalAsyncComputed- Create global async computed values
- Async computed values with
useAsyncComputed - Batching utilities with
batchfunction untrackutility for reading signals without creating dependencies- Built-in type signal operators for enhanced type safety
- Automatic Widget rebuilding integration
- Performance optimizations with alien_signals backend
Features #
- 🚀 High performance reactive system built on alien_signals
- 🪄 Magic in widgets - add reactivity to any existing Widget seamlessly
- 🔄 Automatic dependency tracking and updates
- 🎯 Full type safety with Dart's strong type system
- 🔧 Flexible integration with any Flutter widget
- 📦 Lightweight with minimal overhead
Dependencies #
- Flutter SDK ^3.8.1
- alien_signals ^0.4.2