jaspr_bloc 1.0.1
jaspr_bloc: ^1.0.1 copied to clipboard
A state management package for Jaspr that implements the BLoC pattern, enabling Jaspr apps to handle state the same way as Flutter apps.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Version numbers are aligned with the bloc ecosystem convention:
major versions track breaking changes, minor versions track new components,
and patch versions track bug fixes and documentation updates.
1.0.1 - 2026-03-11 #
Fixed #
- Correct repository URL in
pubspec.yamlto point to the right GitHub repository. - Add top-level
example/example.dartso pub.dev recognizes the example correctly. - Hide undocumented abstract protocol types (
BlocEventSink,Closable,Emittable,EmittableStateStreamableSource,Emitter) from thepackage:blocre-export so all public API elements in jaspr_bloc have dartdoc coverage.
1.0.0 - 2026-03-11 #
Added #
Dependency Injection
BlocProvider— provides aBlocorCubitinstance to a descendant component subtree viaInheritedComponent; creates and closes the bloc automaticallyBlocProvider.value— provides an existing bloc instance without taking ownership of its lifecycle; required for sharing blocs across@clientisland boundariesBlocProvider.of<T>— static accessor to retrieve a bloc from the nearest ancestor providerMultiBlocProvider— composes multipleBlocProviderinstances without deep nestingRepositoryProvider— provides any non-bloc dependency (repositories, services, data sources) to a subtree; does not manage lifecycleRepositoryProvider.value— provides an existing repository instance without ownershipRepositoryProvider.of<T>— static accessor to retrieve a repository from the nearest ancestorMultiRepositoryProvider— composes multipleRepositoryProviderinstances without nesting
Reactive UI
BlocBuilder— rebuilds its subtree on every bloc state emission; supportsbuildWhenpredicate to filter rebuildsBlocListener— runs a side-effect callback on state changes without rebuilding its child; supportslistenWhenpredicate to filter invocationsMultiBlocListener— composes multipleBlocListenerinstances without deep nestingBlocConsumer— combinesBlocBuilderandBlocListenerin a single component backed by one stream subscription; supports independentbuildWhenandlistenWhenpredicatesBlocSelector— rebuilds only when a value derived from the state changes via==equality; accepts aselectorfunction and abuildercallback
Context Extensions
context.read<T>()— retrieves the nearestBlocProvider<T>bloc without subscribing; intended for dispatching events from callbackscontext.watch<T>()— retrieves the nearestBlocProvider<T>bloc and subscribes to rebuild notifications; intended for use insidebuildmethodscontext.select<T, S, R>(selector)— retrieves the nearestBlocProvider<T>bloc, subscribes, and returns a derived value from the current state
SSR Compatibility
- All components are server-side rendering safe; no stream subscriptions are created during SSR and subscriptions activate automatically after client hydration
isClientEnvironment— internal flag that guards stream subscriptions; exposed asresetIsClientForTestingfor unit test isolation
Examples
example/counter/— minimal counter app demonstratingBlocProvider,BlocBuilder,CounterCubit, andcontext.readwithin a@clientcomponentexample/shared_bloc/— mono-repo demonstrating a pure-Dartcommon_blocspackage shared unchanged between a Flutter app and a Jaspr app
Documentation
- Full dartdoc comments on all public APIs with usage examples
doc/client-component-isolation.md— guide for sharing blocs across@clientisland boundaries using theBlocProvider.valueglobal container pattern- Comprehensive README with quick start, per-component code examples, SSR guidance, and a
flutter_blocvsjaspr_bloccomparison table