CacheObservable mixin

A mixin that adds observable capabilities to a cache system. It allows objects to watch changes to specific cache keys and get notified when those keys are updated or deleted. Observers must implement the CacheObserver interface.

This mixin provides methods to add and remove observers for specific keys, and to notify these observers when changes occur.

Usage: A cache class can include this mixin to allow other parts of the application to react to cache updates or deletions.

Mixin applications

Properties

hashCode int
The hash code for this object.
no setterinherited
maxObserversPerKey int
Maximum number of observers per key.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyDeleteObservers(String key) → void
Notifies observers about the deletion of a key. If the special key allKeys is used, all observers for all keys are notified, and the observers map is cleared.
notifyObservers<T>(String key, T newValue) → void
Notifies all observers watching a specific key about a change.
stream<T>(String key) Stream<T>
Returns a Stream that emits values when a specific cache key is updated.
toString() String
A string representation of this object.
inherited
unwatch<T>(String key, [CacheObserver<T>? observer]) → void
Removes an observer for a specific cache key.
watch<T>(String key, CacheObserver<T> observer) → void
Adds an observer for a specific cache key.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

allKeys → const String
A constant for representing notifications for all keys.