LiveQuery<E> class
A live query that automatically re-executes when box data changes.
LiveQuery wraps a query execution function and a Box.watch() stream. Whenever the underlying data changes, the query is re-executed and the latest results are emitted to all subscribers.
This class handles:
- Debouncing rapid changes to avoid excessive re-computation
- Proper subscription lifecycle management
- Error handling and recovery
Usage:
final liveQuery = LiveQuery<int>(
box: myBox,
execute: () => myBox.query()
.where('age', greaterThan: 18)
.findAll(),
);
liveQuery.stream.listen((results) {
print('Found ${results.length} adults');
});
// Don't forget to dispose when done
liveQuery.dispose();
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
lastResults
→ List<
E> ? -
The most recent query results, or null if the query hasn't run yet.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ Stream<
List< E> > -
The stream of query results.
no setter
Methods
-
dispose(
) → void - Dispose this live query and release all resources.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refresh(
) → void - Manually trigger a refresh of the query results.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited