CacheObserver class
An observable cache that emits updates when entities change.
CacheObserver is the bridge between mutation UseCases and listening SignalSlices. When a mutation updates the cache, all observers for that entity type are notified.
// Mutation UseCase
await updateProductUseCase.call(params);
CacheObserver.instance.notify<Product>(updatedProduct);
// View B's slice automatically receives the update
final slice = presenter.slice<Product>('product');
slice.listen((data, _) => print(data)); // fires with updatedProduct
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
dispose<
T> () → void -
Dispose the stream for type
T. Called when no views are active. -
hasListeners<
T> () → bool -
Whether any listeners are active for type
T. -
listen<
T> (void callback(T? entity, String? deletedId)) → SignalSubscription -
Listen to cache updates for type
T. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notify<
T> (T entity) → void -
Notify all listeners that an entity of type
Thas been updated. -
notifyDelete<
T> (String id) → void -
Notify all listeners that an entity of type
Thas been deleted. -
reset(
) → void - Clear all cached streams. Primarily for testing and app reset.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → CacheObserver
-
final