scoped_store 0.2.2
scoped_store: ^0.2.2 copied to clipboard
Minimal reactive-store + scoped dependency injection for Flutter. Retain and release stores by reference count, wire them into widgets with one line, rebuild on value change. Five files, zero codegen.
0.2.2 #
Documentation-only release. Rewrote the README to cover the 0.2.x API:
removed the StoreRegistry section (gone since 0.2.0), added side-by-side
examples for all four widget styles (StoreBuilder, OwnedStoreView,
StoreView, StoreStateMixin), documented *ById keyed instances,
registerFactory lazy singletons, the AutoReleaseScopedStore mixin,
and a testing pattern. No code changes.
0.2.1 #
GetX-style helpers for screens that read or own a store, so screens don't
have to call StoreManager.instance directly or nest a StoreBuilder.
Added #
StoreView<T>— stateless base. Exposes astoregetter viaStoreManager.instance.get<T>()(orgetById<T>whenidis overridden). No lifecycle; assumes a parent owns the retain.OwnedStoreView<T>— stateful base that owns the lifecycle. OverridecreateStore()andbuild(context, store); the widget retains oninitStateand releases ondispose. Supports id-keyed instances via theidoverride.StoreStateMixin<T, W>— mixin for existingState<W>classes that need the same retain/release lifecycle without changing the base class. OverridecreateStore()(and optionallystoreId) and access the store via thestoregetter.
0.2.0 #
Reworked StoreManager to own its instance cache directly, decoupling
scoped lifecycle from the underlying get_it container. Adds id-keyed
stores so multiple instances of the same type can coexist, and a mixin
for auto-releasing retains on dispose.
Breaking #
- Removed
StoreRegistry. UseretainById<T>/releaseById<T>/getById<T>onStoreManager(or the global shorthands) for keyed instances of the same type. StoreManagerno longer registers retained instances in the underlying container or unregisters them on release. It now holds its own instance cache, so a get_it factory registration (e.g.@injectable) won't break refcounting by handing out fresh instances on everyget<T>().
Added #
retainById<T>(id, [factory]),releaseById<T>(id),getById<T>(id),tryGetById<T>(id),getRefCountById<T>(id)for managing multiple instances of the same type, keyed by a runtime id.tryGet<T>()global shorthand — returns null instead of throwing.registerFactory<T>global shorthand for lazy factory registration. First lookup auto-retains; matchingreleasedisposes when refcount hits zero.AutoReleaseScopedStoremixin (onDisposable) — recordsretainStore<T>/retainStoreById<T>calls and releases them in LIFO order fromonDispose.- Debug-mode warnings when more than one
StoreManageris constructed in a single isolate (hot restart, second isolate, or singleton bypass). ExposesinstanceIdandtotalInstancesCreated.
0.1.0 #
Initial release. Three files — reference-counted store lifecycle, zero opinions about how your state updates.
StoreManager— singleton DI registry withretain<T>/release<T>/get<T>/tryGet<T>/getWithKey/ scoped child registries.StoreBuilder<T>— widget that retains a store for its subtree and releases it on dispose. Pair with any reactive builder.StoreRegistry— keyed registry for multiple instances of the same type.
No reactive primitive is included. Bring your own: ChangeNotifier,
ValueNotifier, Riverpod, Bloc, signals — anything a store can hold
and a Flutter widget can listen to.