event_bus_riverpod 3.2.7
event_bus_riverpod: ^3.2.7 copied to clipboard
Type-safe event bus with Riverpod integration for Flutter.
3.2.7 #
- README: added a callout after the description pointing to
event_bus_global— the same event bus without the Riverpod dependency — for users not using Riverpod.
3.2.6 #
- 16 — SubEvents:
SubEventIdentifier.subEventNamerenamed toeventNamefor consistency with the newEventBusIdentifierBase<T>they both extend. Breaking change. - 20 — Global API: use the event bus from anywhere without Riverpod — plain Dart classes, services, or repositories.
EventBusGlobal.event()andEventBusGlobal.subEvent()work with the same singleton bus asref.event(), so emits and listeners are shared across both worlds. - 21 — EventBusBuilder: new widget that rebuilds whenever an event or subEvent fires. Accepts both identifier types polymorphically. No subscription management needed — handles
initState,dispose, and re-subscription on changes automatically. - 19 — Logger interceptor:
logEvents()now supports multiple independent callbacks — each registration adds to a stack instead of replacing the previous one. Providers, widgets, and the global API can all log concurrently without overwriting each other. Each logger is cleaned up individually on dispose. - 22 —
waitFor(): await the next emission as aFuture<T>— ideal for navigation after login, waiting for a specific status, or any one-shot coordination. Available on events, subEvents, and the global API. Built-in 30-second timeout prevents hanging futures; supportswherefilter for conditional matching. Includes awaitForWithMeta()variant that returnsFuture<(T, BusMetadata)>. - Bug fixes:
- Fixed
SubEventAction.lastValueandSubEventAction.historysilently registering the subEvent as a side effect — reads are now pure lookups. - Fixed
emitAsync()dropping events when an async middleware callsnext()after anawait— the middleware chain now awaits completion correctly. - Fixed
_subEventBackfilledNoMatchnot being cleaned up when a later parent emission matches the subEvent'swherefilter, preventing new sticky listeners from receiving the cached value. - Fixed
_tryDeliverStickyand related methods silently swallowing all errors — now logged in debug mode, consistent with_invokeListeners. - Fixed
_removeSubEventListenerandclearSubEventscanning all parent events to find a subKey — O(n) → O(1) via a reverse_subKeyToParentKeymap. - Fixed
setHistorySizebeing called on everyemit()andhistoryread — now no-op if the size is already set. - Fixed
EventBusBuildernot passingstickytolistenManuallyon re-subscriptions, causing thewherefilter to be ignored for sticky delivery. - Fixed
EventBusCore.waitForand friends missing a default timeout — now consistent with the abstract class (30s default). - Removed unused
autoDisposeparameter fromlisten()and friends — always disposes onref.onDisposeas there was no way to manually dispose without the return value. - Fixed
listenOnce()/onOnce()not respecting listenerpriorityordering — now runs in correct order alongside regular listeners.
- Fixed
2.9.3 #
- Shortened package description to stay within pub.dev's 180-character limit.
- Added example directory with a working Flutter app demonstrating event bus usage.
- Fixed lint warnings (
curly_braces_in_flow_control_structures) in_fireSubEventsand_fireSubEventsAsync.
2.9.2 #
- Logger interceptor: global
ref.logEvents()callback fires for every event emission before middlewares — value, name, and metadata included. Error-isolated. Auto-dispose forRef, manual forWidgetRef. Documented in section "19. Logger interceptor". - Broadcast streams: added
broadcastparameter (falseby default) tostream(),streamWithMeta(),streamSubEvent(), andstreamWithMetaSubEvent(). Whentrue, multiple subscribers can listen on the same stream without errors. Documented in section "8. Stream API — Broadcast mode". clearAllEvents(): new extension method on bothRefandWidgetRefthat wipes all listeners, subEvent listeners, middlewares, sticky caches, and subEvent registrations in one call. Useful for fully resetting state during user logout or app teardown. Documented in section "9. Clear all listeners — Clear all events".- One-shot listeners (
listenOnce): newlistenOnce()/listenOnceManually()on events and subEvents — the listener fires on the next emission and immediately removes itself. Auto-dispose (listenOnce) for providers and manual (listenOnceManually) for widgets, both with sticky, where, metadata, priority, and error handling support. - Event history (last N values): new
historygetter onEventBusAction<T>andSubEventAction<T>that returns a circular buffer of the last N emitted values with theirBusMetadata, configured viaEventBusIdentifier(historySize: N).clearHistory()empties the buffer without affecting listeners or sticky cache. SubEvents have their own independent history. Default is0(no history, zero overhead). Documented in section "18. Event history". - Better performance on default-priority listeners: when every listener uses the default
priority: 0, event delivery now runs in linear time instead of sorting — speeds up emissions for the vast majority of use cases. - Reduced code duplication and more consistent internals: the action layer was refactored to share common logic via mixins, and the listener notification pipeline (sync, async, subEvents) was unified into a single internal function — less code, fewer bugs, and identical behavior across all event types.
- Bug fixes:
- Fixed the
wherefilter parameter being silently ignored when listening manually with metadata in async mode (listenManuallyAsyncWithMeta) — listeners would receive all events instead of only matching ones. - Fixed
emitAsync()hanging forever when a middleware cancels the event by not callingnext()— now resolves correctly without waiting for a cancelled event. - Fixed a rare edge case where removing listeners during cleanup could cause some internal entries to be skipped.
- Fixed subEvents with a
wherefilter that doesn't match the parent's last cached value repeatedly re-checking that same value on every new sticky subscription — now skips unnecessary checks when the parent value hasn't changed.
- Fixed the
2.6.1 #
- 17 —
lastValuegetter on events and SubEvents: read the last emitted value directly without subscribing.EventBusAction<T>.lastValueandSubEventAction<T>.lastValuereturnT?— the sticky-cached value ornullif nothing has been emitted yet (or afterclearSticky()). SubEvents auto-register and backfill on first access. See section 17 in README for examples.
2.6.0 #
- 16 — SubEvents: filtered views of events with their own listener list, sticky cache, and a mandatory
wherepredicate. Access viaref.subEvent()on bothRefandWidgetRef. Listen-only — noemit()oremitAsync()— auto-triggered when the parent event emits. Sticky cache is independent of the parent; backfills from the parent on first subscription. See section 16 in README for details and examples.
2.5.2 #
- Removed
BusMetadataForEmit:emit()andemitAsync()now acceptsourceandextraDataas direct optional parameters instead of requiring aBusMetadataForEmitwrapper.
2.5.1 #
- 10 — Async listeners:
listenAsync()for async callbacks (API calls, DB ops) andemitAsync()that awaits all async listeners before resolving. Sync and async listeners can coexist. - 11 — Sticky events: cache the last emitted value and deliver it to new subscribers with
sticky: trueon all listen methods. NewclearSticky()to clear the cache without removing listeners. - 12 — Middleware pipeline: intercept, transform, or cancel events before they reach listeners with
applyMiddleware(). Each middleware can log, modify the value, or cancel by not callingnext(). NewclearMiddlewares()to remove all middlewares. - 13 — Execution priority: added
priorityparameter to all listen methods; higher values run first (default0, negative values supported). - 14 — BusMetadata: every emission carries an auto-generated
timestamp; optionally attach asourceand arbitraryextraDataviaBusMetadataForEmit. Access metadata with*WithMetalistener methods. Sticky cache preserves metadata alongside the value. - 15 — Listener filter with
where: all listen methods accept awherepredicatebool Function(T value, BusMetadata metadata)to conditionally receive emissions. Errors inwhereare caught and logged per-listener. Sticky delivery respects the filter. - Bugs fixed:
- Fixed memory leak in
stream()—_ListenerEntrywas added to_listenersimmediately even if no one subscribed to the stream; now added only ononListenofStreamController. - Removed dead
onErrorparameter fromstream()— the callback never throws (controller.add), so the parameter was misleading. - Fixed
hasClientsgetter mutating internal state — disposed listener cleanup moved out of the getter.
- Fixed memory leak in
- Improvements:
ListenerDisposablereplaceddart:uiVoidCallbackwithvoid Function()— removes unnecessary dependency.- Added
toString()toEventBusIdentifier<T>— easier debugging and logging. - Cached
_keyinEventBusIdentifier—_buildKeyno longer recalculates the hash on every call. - Updated API documentation with examples for all new parameters.
1.6.2 #
- Error handling: added
onErrorcallback tolisten(),listenManually(), andstream()for per-listener error handling. Errors are logged vialog()in debug mode when noonErroris provided. - Stream API: added
stream()method to expose events asStream<T>forStreamBuilder, stream composition (.where(),.map()), and Riverpod memoization. - Key routing: stored
TypeinEventBusIdentifier<T>and switched toObject.hash(eventName, T)for robust, platform-independent key generation (replaced fragileT.toString()). - Clear listeners: added
clearListeners()to remove all listeners of a specific event without affecting others. - Updated README with documentation and examples for all new features.
1.2.5 #
- Updated README with additional information.
1.2.4 #
- Added API documentation comments with example code above every function in
EventBusAction,EventBusActionForRef, andEventBusActionForWidgetRef.
1.2.3 #
- Internal reorganization: moved implementation files to
lib/src/to make them package-private. Onlyevent_bus_riverpod.dartis now importable from outside the package.
1.2.2 #
- Bumped minimum required
flutter_riverpodversion down to>=3.0.0.
1.2.1 #
- Added pub.dev link to README.
1.2.0 #
- Initial release of the
event_bus_riverpodpackage. - Typed event bus:
EventBusIdentifier<T>to define type-safe events. - Dual context:
EventBusForRefandEventBusForWidgetRefextensions forRefandWidgetRef. - Lifecycle management: auto-dispose subscription via
ref.onDisposeand manual subscription withListenerDisposable. - Emit and inspect:
emit()to fire events andhasClientsto check for active subscribers.