LogWindow class final

Loaded window of the log under filter: entries newest first, with no duplicates by StoredLogEntry.id, contiguous from the newest entries to the last one loaded; next follows it. The list model for a viewer that reads the log in pages and receives store changes (LogStoreChange); independent of the UI.

The window grows by query pages (query, LogPage.next) and changes in place on store events (apply): new entries take their place by time, removed ones are dropped by id, the oldest ones over the limit are discarded (trim). While a store query is running (beginQuery), changes are additionally remembered: the query result is a snapshot of an unknown moment, which may or may not include them. On completion (completeQuery) the page is merged into the window by id, and the remembered changes are applied on top of it in the original order; all operations are idempotent, so the result is correct either way. Until the first page is loaded (isLoaded), there is nothing to apply changes to: they are only remembered.

An entry older than the loaded window is not inserted while there is a continuation: the next page will load it, and the window stays contiguous. LogStoreInvalidated is not handled by the window: it means a reload, which is the owner's job.

final window = LogWindow(filter: filter, pageSize: 100);
window.beginQuery();
final page = await reader.queryEntries(window.query);
window.completeQuery(page);
reader.changes.listen(window.apply);

Constructors

LogWindow({required LogFilter filter, required int pageSize})

Properties

addedTags → Set<String>
Tags of entries added to the store while the window exists (LogEntriesAdded), including those not matching filter: a tag list requested from the store before these entries does not contain them.
no setter
entries → List<StoredLogEntry>
The window's entries, newest first.
no setter
filter → LogFilter
Conditions selecting the window's entries.
final
hashCode → int
The hash code for this object.
no setterinherited
isLoaded → bool
Whether the first page is loaded (completeQuery).
no setter
isQuerying → bool
Whether a store query is running (beginQuery without completeQuery or failQuery).
no setter
next → LogQuery?
Query for the next page of older entries; null means there are no more pages.
no setter
pageSize → int
How many entries to request at a time (query).
final
query → LogQuery
First-page query: entries under filter, newest first, pageSize at a time.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

apply(LogStoreChange change) → bool
Applies a store change to the window (except LogStoreInvalidated). During a query also remembers it. Returns whether the window changed.
beginQuery() → void
Marks the start of a store query: changes until its completion are remembered to be applied on top of the result.
completeQuery(LogPage page) → bool
Merges page and applies on top of it the changes that arrived during the query; the window is loaded afterwards (isLoaded). The continuation comes from the page, unless everything was removed during the query.
failQuery() → void
Marks the query as failed: remembered changes are discarded (they are already applied to the window if it is loaded).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
trim(int max) → bool
Discards the oldest entries over max; the next page starts right after the last remaining one. Not during a store query: its result would continue the discarded part. Returns whether the window changed.

Operators

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