store_scope 0.2.0
store_scope: ^0.2.0 copied to clipboard
Flutter's Jetpack ViewModel — widget-tree-scoped dependency injection with automatic disposal, zero codegen, and bring-your-own reactivity.
0.2.0 #
- Add provider overrides for tests/DI. Inject fakes via
StoreScope(overrides: [...])orStoreImpl(overrides: [...]), built withprovider.overrideWithValue(fake)(caller owns the instance's lifecycle) orprovider.overrideWith((space) => fake, dispose: ...). - BREAKING: acquiring a store-lifetime instance is now
Store.share/StoreSpace.share/context.share(wasread). It accepts only aSharedProviderand pairs with theProvider.shared(...)definition. Migration: replaceread(withshare(at those call sites. - Added store-lifetime argument providers: mark a
withArgumentfactory.asSharedat the definition site, then acquire per-argument singletons withstore.share(p(arg)). Keyed by the argument's value and alive until the Store is unmounted; available on every arity (withArgument..withArgument6) for bothProviderandViewModelProvider. Example:final userProvider = Provider.withArgument<User, int>((s, id) => User(id)).asShared; - BREAKING (low impact): the per-arity argument-provider factories were unified into a single internal provider class; their public
createInstance/createViewModelhelper methods were removed. Acquire instances the usual way — call the factory (factory(arg)) thenspace.bind(...)/store.share(...). Code that called those helpers directly must drop them. - Fixed dartdoc examples that referenced removed/incorrect APIs (
store.shard,context.bindWith, a non-existentDisposeStateAwareMixin).
0.1.0 #
- BREAKING: Instance lifetime is now declared on the provider.
Store.shared()is removed — define store-lifetime instances withProvider.shared(...)/ViewModelProvider.shared(...)and read them via the scope-free, statically typedStore.read/context.read. Scoped providers keep usingbind/bindWith. - Fix:
Store.unmount()now disposes every instance; ViewModels and their subscriptions were previously leaked on teardown. - Fix:
ViewModel.dispose()no longer throwsConcurrentModificationErrorwhen a closeable registers another closeable. - Fix: swapping
StoreScope.storeOwnerno longer throwsLateInitializationError. - Remove the internal shared-instances tracking and the assert-only shared/bind misuse warnings.
0.0.11 #
- ViewModel add addSubscription method
- Add temporary method of Store to support creation of temporary instances
- Introducing ScopedBuilder to simplify the interaction between components and Store
0.0.10 #
- Introducing AutoStoreWidget and AutoStoreStatefulWidget to simplify state management and automatically handle the Store lifecycle
0.0.9 #
- Make viewModel inherit from ChangeNotifier to optimize resource destruction processing
0.0.8 #
- Refactor ArgProvider and ArgViewModelProvider to support custom equality
0.0.7 #
- Add instance scope manager to optimize instance creation and destruction process
0.0.6 #
- Provide a default implementation for the disposeViewModel method
0.0.5 #
- Support passing in parameters when creating a provider
0.0.4 #
- Allow access to store in initState; widget tree rebuilds on store changes
0.0.3 #
- Refactor code to use the new ScopeAware interface, optimizing binding and lifecycle management
0.0.2 #
- fix: change the parameter name
0.0.1 #
- Initial version.