all_observer 1.0.0
all_observer: ^1.0.0 copied to clipboard
Lightweight reactive state management for Flutter with zero external dependencies. Observable values and an auto-tracking Observer widget, built for safety (no rebuilds on defunct elements) and full V [...]
1.0.0 #
Initial release.
Core:
Observable<T>reactive value, plusObservableInt,ObservableDouble,ObservableBool,ObservableString..obsextension for creating observables from literals and collections.ObservableList,ObservableMap,ObservableSetreactive collections; reading any member tracks it, mutating any member notifies at most once per call — bulk operations (addAll,removeWhere,retainWhere,insertAll,clear,sort,shuffle) never notify once per element, and no-op mutations (adding a duplicateSetelement,removeWherethat removes nothing,map[k]=vwith an identical value,clear()on an already-empty collection) don't notify at all.Observerwidget with automatic, stack-based dependency tracking and safe rebuild scheduling (no "defunct element" crashes).ObserverValuefor self-contained local reactive state.Computed<T>: lazy, memoized derived values reusing the same dependency tracker asObserver; supports dynamic/conditional dependencies; only notifies when the derived value actually changes;close()unsubscribes from all current dependencies.Observable.batch(() { ... }): coalesces multiple writes inside the callback into a single notification per changed observable/collection for manual (listen/ever) subscribers, with nested-batch support.equalsparameter on theObservable<T>constructor, for custom change-detection (e.g. floating-point tolerance) instead of==.listen/ObservableSubscription, stream-free manual subscriptions.- Workers:
ever,once,debounce,interval, plusWorker/Workers.
Robustness:
- An exception thrown inside one
ever/listencallback does not stop other listeners of the same observable from running; it is reported viaFlutterError.reportError(library: 'all_observer') instead of being swallowed or propagating. - A synchronous update cycle (a listener of A writing to B, whose listener writes back to A) stops after a bounded notification depth with a descriptive
FlutterError, instead of crashing with a raw stack overflow. Observer: if the builder throws during a tracked build, dependency disposers accumulated up to that point are still assigned, so the next build/unmount does not leak or double-register listeners.- The "write during build" warning covers both
Observable.value =and reactive-collection mutations, andObserverConfig.strictModeturns this case into a thrownObserverErroras well as the "empty Observer" case. listen()/close()on an already-close()dObservable/collection returns an inert (already-canceled) subscription instead of silently registering a listener that can never fire; a mutation attempted on a closed collection is a full no-op (the underlying data is left untouched), and double-close()is safe.- Documented, in
Observable's dartdoc, that writing to an observable from a different isolate does not work (no cross-isolate synchronization is attempted).
Other:
- Debug-only, ANSI-colored logging via
ObserverConfigand non-fatal misuse warnings (with optionalstrictMode). - Zero external dependencies; full
ValueListenableinteroperability.
See AUDIT_REPORT.md at the repository root for the full item-by-item performance/robustness audit this release was validated against.