DwWindowRequest<T extends DwDataObject, S extends Object, I extends Object> class abstract

A window over a long, newest-first sequence (a chat, a log), read in both directions from an anchor.

Without an anchor the window opens at the newest rows. Loading older or newer rows goes by the cursors of DwWindowResult, which the server builds from positionOf (DwWindowCursor), so rows sharing a sort value are neither lost nor repeated.

positionOf is the one definition of the sequence's order: the server builds cursors and checks a client's cursors with it, and the client decides with it where an object arriving live belongs. S is the sort value (int, String or DateTime), I the id (int or String).

final class ListChat extends DwWindowRequest<ChatMessage, DateTime, int>
    with _$ListChat {
  const ListChat({required this.roomId}) : super(pageSize: 30);
  final int roomId;
  @override
  DwWindowPosition<DateTime, int> positionOf(ChatMessage item) =>
      (sortValue: item.sentAt, id: item.id);
}

pageSize and maxPageSize are constants of the class, as in DwPageRequest.

Default update: matches ? upsert : remove — an object in the window is replaced; a new matching one is inserted where positionOf puts it when that is inside the loaded range: newer than the newest row only while the window shows the newest rows (hasNewer false — otherwise the window counts it as unseen), older than the oldest row only while it shows the oldest (hasOlder false — otherwise it appears on loading older rows). One that stops matching, or a deletion, is removed.

Inheritance

Constructors

DwWindowRequest({required int pageSize, int? maxPageSize})
const

Properties

channels → List<DwLiveChannel>
The channels whose updates this request's state absorbs while it is watched. Subscriptions are reference-counted across requests.
no setterinherited
dwTypeName → String
The name this class travels under. Unique across the protocol.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
maxPageSize → int
The most rows one call is served; pageSize unless the class allows more.
no setter
pageSize → int
Rows per load when the call does not ask for another size.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

acceptsDeletion(DwDeletedObject deletion, DwWireProtocol protocol) → bool
Whether deletion removes an object of this request's item type.
override
acceptsItem(Object? item) → bool
Whether item is an instance of this request's item type.
override
compareItems(T a, T b) → int
Compares the positions of a and b: positive when a is newer.
cursorOf(T item) → String
The cursor string of item's position.
decodeResult(Object? json, DwWireProtocol protocol) → DwWindowResult<T>
Decodes a result of this call from the wire (client side). Throws FormatException when json is not a result of this call.
override
encodeResult(DwWindowResult<T> result, DwWireProtocol protocol) → Object?
Encodes a result of this call for the wire (server side).
override
matches(T item) → bool
Whether item belongs to this window's sequence. By default every object of type T on the request's channels does.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onUpdate(Object item) → DwUpdateAction
What an arrived object does to this request's state.
inherited
positionOf(T item) → DwWindowPosition<S, I>
item's place in the sequence: its sort value and its id. A pure function of the object — the same column the server's handler orders by, or cursors and live inserts disagree with the rows it reads.
servedPageSize(int? asked) → int
The rows a call asking for asked (null: not asking) is served.
toJson() → Map<String, Object?>
The fields of this DTO as JSON. Absent optional fields are omitted — the wire carries nothing the receiver can do without.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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