@softwarity/livewire 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,118 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, computed, inject, signal } from '@angular/core';
2
- import { LivewireClient } from './livewire.client';
3
-
4
- /** How long the indicator acknowledges a click before going back to its state. */
5
- const ACKNOWLEDGE_MS = 700;
6
-
7
- /**
8
- * Whether the socket is up, and the one thing to do about it when it is not.
9
- *
10
- * That and nothing else - not whether anything is arriving on it, which is a
11
- * different question and one this would answer badly: a quiet feed at three in
12
- * the morning is not a fault.
13
- *
14
- * Clicking it retries. Down, that opens the socket now instead of waiting out
15
- * the reconnection delay; up, it asks every open window for a fresh snapshot.
16
- * It is deliberately not a refresh button on the list: on a live screen a
17
- * control offering to fetch it again implies that the rest of the time you are
18
- * looking at something stale.
19
- *
20
- * Colours come from CSS custom properties, so a host theme dresses it without
21
- * this package knowing anything about the theme:
22
- *
23
- * ```css
24
- * lw-live-indicator { --lw-live: #1b7f3b; --lw-down: #b26a00; }
25
- * ```
26
- */
27
- @Component({
28
- selector: 'lw-live-indicator',
29
- changeDetection: ChangeDetectionStrategy.OnPush,
30
- standalone: true,
31
- template: `
32
- <button type="button" class="lw-indicator" [class.lw-down]="!live()" [attr.aria-label]="label()" [title]="label()" (click)="retry()">
33
- <span class="lw-dot" [class.lw-beat]="live() && !asked()" [class.lw-turn]="asked()"></span>
34
- </button>
35
- `,
36
- styles: [
37
- `
38
- :host {
39
- display: inline-flex;
40
- }
41
- .lw-indicator {
42
- display: inline-flex;
43
- align-items: center;
44
- padding: 0;
45
- border: none;
46
- background: none;
47
- cursor: pointer;
48
- color: var(--lw-live, currentColor);
49
- }
50
- .lw-indicator.lw-down {
51
- color: var(--lw-down, #b26a00);
52
- }
53
- .lw-indicator:focus-visible {
54
- outline: 2px solid currentColor;
55
- outline-offset: 2px;
56
- border-radius: 50%;
57
- }
58
- .lw-dot {
59
- display: block;
60
- width: 0.6rem;
61
- height: 0.6rem;
62
- border-radius: 50%;
63
- background: currentColor;
64
- }
65
- .lw-dot.lw-beat {
66
- animation: lw-beat 1s ease-in-out infinite;
67
- }
68
- .lw-dot.lw-turn {
69
- animation: lw-turn 0.5s ease-out;
70
- }
71
- @keyframes lw-beat {
72
- 0%,
73
- 90% {
74
- transform: scale(1);
75
- }
76
- 45% {
77
- transform: scale(1.35);
78
- }
79
- }
80
- @keyframes lw-turn {
81
- from {
82
- transform: scale(1.6);
83
- opacity: 0.4;
84
- }
85
- }
86
- @media (prefers-reduced-motion: reduce) {
87
- .lw-dot.lw-beat,
88
- .lw-dot.lw-turn {
89
- animation: none;
90
- }
91
- }
92
- `,
93
- ],
94
- })
95
- export class LiveIndicatorComponent {
96
- private readonly client = inject(LivewireClient);
97
-
98
- readonly live = this.client.live;
99
-
100
- /**
101
- * Set for a moment after a click, and read for nothing but the animation.
102
- *
103
- * A resync on a list that has not moved changes no pixel, so without this the
104
- * gesture looks like it did nothing at all.
105
- */
106
- readonly asked = signal(false);
107
-
108
- readonly label = computed(() => (this.live() ? LIVE : DOWN));
109
-
110
- retry(): void {
111
- this.client.retry();
112
- this.asked.set(true);
113
- setTimeout(() => this.asked.set(false), ACKNOWLEDGE_MS);
114
- }
115
- }
116
-
117
- const LIVE = 'Live - click to ask for the data again';
118
- const DOWN = 'Disconnected - reconnecting. Click to try now';
@@ -1,94 +0,0 @@
1
- import { signal } from '@angular/core';
2
- import type { Signal } from '@angular/core';
3
- import type { LiveRow, PatchFrame, UpdateFrame } from '@softwarity/livewire-protocol';
4
-
5
- /**
6
- * A list kept in step with what the server pushes.
7
- *
8
- * Snapshot then patches, applied and nothing more: what belongs in the list and
9
- * in what order is decided by the source's query, and a client that recomputed
10
- * either from its own idea of the filters would be a second implementation free
11
- * to disagree.
12
- */
13
- export class LiveList<Row extends LiveRow> {
14
- private readonly held = signal<Row[]>([]);
15
- private readonly length = signal(0);
16
- private readonly marked = signal<number | null>(null);
17
-
18
- /** The list as it stands. Ordered by the server, never re-sorted here. */
19
- readonly rows: Signal<Row[]> = this.held.asReadonly();
20
-
21
- /** What the list is a page of, for a paged topic. Its own length otherwise. */
22
- readonly total: Signal<number> = this.length.asReadonly();
23
-
24
- /**
25
- * An index in the whole list the server pointed at, if it pointed at one.
26
- *
27
- * Meaningless here on purpose: the library carries the number and the screen
28
- * decides what it means - a boundary, a cursor, the first unread row.
29
- */
30
- readonly pivot: Signal<number | null> = this.marked.asReadonly();
31
-
32
- private sequence = 0;
33
-
34
- /**
35
- * Applies one frame. Answers false when the two sides have drifted, which is
36
- * the caller's cue to ask for the window again.
37
- */
38
- apply(update: UpdateFrame<Row>): boolean {
39
- if (update.type === 'error') {
40
- console.error(`Livewire subscription '${update.id}' refused: ${update.reason}`);
41
- return true;
42
- }
43
- if (update.type === 'snapshot') {
44
- this.sequence = update.sequence;
45
- this.held.set(update.rows);
46
- this.length.set(update.total ?? update.rows.length);
47
- this.marked.set(update.pivot ?? null);
48
- return true;
49
- }
50
- // On one socket nothing is lost and nothing overtakes, so a gap means the
51
- // two sides disagree about what was sent. Asking again is cheap; carrying
52
- // on would show a list nobody can reproduce.
53
- if (update.sequence !== this.sequence + 1) {
54
- return false;
55
- }
56
- const rebuilt = this.rebuild(update);
57
- if (!rebuilt) {
58
- return false;
59
- }
60
- this.sequence = update.sequence;
61
- this.held.set(rebuilt);
62
- this.length.set(update.total ?? rebuilt.length);
63
- this.marked.set(update.pivot ?? null);
64
- return true;
65
- }
66
-
67
- /** Forgets what it holds - a fresh subscription answers with a snapshot. */
68
- reset(): void {
69
- this.sequence = 0;
70
- this.held.set([]);
71
- this.length.set(0);
72
- this.marked.set(null);
73
- }
74
-
75
- /** Null when the patch names a row neither side holds - the caller resyncs. */
76
- private rebuild(update: PatchFrame<Row>): Row[] | null {
77
- const byId = new Map(this.held().map((row) => [row.id, row]));
78
- for (const id of update.removed) {
79
- byId.delete(id);
80
- }
81
- for (const row of update.upserted) {
82
- byId.set(row.id, row);
83
- }
84
- const next: Row[] = [];
85
- for (const id of update.order) {
86
- const row = byId.get(id);
87
- if (!row) {
88
- return null;
89
- }
90
- next.push(row);
91
- }
92
- return next;
93
- }
94
- }
@@ -1,83 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { filter, map } from 'rxjs/operators';
3
- import { LiveList } from './live-list';
4
- import { LivewireClient } from './livewire.client';
5
- import type { JsonValue, LiveRow, UpdateFrame } from '@softwarity/livewire-protocol';
6
-
7
- /**
8
- * One screen's live window on one topic.
9
- *
10
- * The bookkeeping every feature service would otherwise repeat: the counter,
11
- * the id it last opened, and the resync that has to name it. Small, and worth
12
- * having once - the id rule below is the kind of thing that is right in one
13
- * copy and wrong in the next.
14
- */
15
- export class LiveTopic<Row extends LiveRow> {
16
- /** Counts subscriptions, so no two ever share an id. */
17
- private opened = 0;
18
-
19
- /** The id of the current window, for `resync`. */
20
- private watching: string | null = null;
21
-
22
- constructor(
23
- private readonly client: LivewireClient,
24
- private readonly topic: string,
25
- ) {}
26
-
27
- /**
28
- * The rows the screen is showing, and again whenever they change.
29
- *
30
- * One subscription for the screen, not one per page: the window is part of
31
- * the question, which is what makes a paged list pushable at all. The server
32
- * does not send an insertion for the client to place - it sends what rows
33
- * `[offset, offset+limit)` now hold, so three rows arriving at the top shift
34
- * no index. The window simply holds something else than it did.
35
- */
36
- window(query: object, offset: number, limit: number): Observable<UpdateFrame<Row>> {
37
- // Unique per subscription. Reusing an id means a patch still in flight from
38
- // the window before lands on the new one, whose sequence starts over - it
39
- // reads as a gap, resyncs, and nothing publishes in the meantime.
40
- this.watching = `${this.topic}:${(this.opened += 1)}`;
41
- return this.client.watch<Row>(this.watching, this.topic, { ...query, offset, limit } as JsonValue);
42
- }
43
-
44
- /**
45
- * The same, for a list the server sends whole.
46
- *
47
- * A short list is bounded by its filters rather than by a scroll position, so
48
- * there is no offset to send. Everything around it is unchanged: one live
49
- * subscription at a time, a fresh id each time, and a resync that names it.
50
- */
51
- open(query: JsonValue | null): Observable<UpdateFrame<Row>> {
52
- this.watching = `${this.topic}:${(this.opened += 1)}`;
53
- return this.client.watch<Row>(this.watching, this.topic, query);
54
- }
55
-
56
- /** Asks the server for the window again - answered with a snapshot. */
57
- resync(): void {
58
- if (this.watching) {
59
- this.client.resync(this.watching);
60
- }
61
- }
62
- }
63
-
64
- /**
65
- * A short list, kept in step: the values that actually exist.
66
- *
67
- * Not a constant in the screen - offering a filter for something an
68
- * installation has never seen answers nothing. These lists are small and
69
- * unpaged, so there is one subscription per topic and its id is the topic.
70
- */
71
- export function liveLabels(
72
- client: LivewireClient,
73
- topic: string,
74
- query: JsonValue | null = null,
75
- ): Observable<{ id: string; label: string }[]> {
76
- const list = new LiveList<LiveRow & { label?: string }>();
77
- return client.watch<LiveRow & { label?: string }>(topic, topic, query).pipe(
78
- filter((update) => list.apply(update)),
79
- // A topic that sends no label is a list of bare values - the value is its
80
- // own label.
81
- map(() => list.rows().map((row) => ({ id: row.id, label: row.label ?? row.id }))),
82
- );
83
- }
@@ -1,364 +0,0 @@
1
- import { DataSource } from '@angular/cdk/collections';
2
- import { signal } from '@angular/core';
3
- import { BehaviorSubject, Observable, Subscription } from 'rxjs';
4
- import { LiveList } from './live-list';
5
- import type { ChangeDetectorRef } from '@angular/core';
6
- import type { CollectionViewer, ListRange } from '@angular/cdk/collections';
7
- import type { LiveRow, UpdateFrame } from '@softwarity/livewire-protocol';
8
-
9
- /**
10
- * How many rows a window holds when the caller does not say.
11
- *
12
- * Fixed per screen, never derived from the viewport: a window sized from the
13
- * rendered range would change with it - 58 rows here, 59 there - and every
14
- * change is a new question, whose answer republishes, which makes the viewport
15
- * emit again. That loop freezes the renderer outright. Only the offset moves.
16
- *
17
- * The number is a transport budget, not a display choice. Some proxies silently
18
- * drop a WebSocket frame past ~64 kB and close the connection rather than the
19
- * frame, leaving the screen empty with no error anywhere. The rule is
20
- * `rows x bytes-per-row < the ceiling you tested`, and the bytes differ per
21
- * screen. Measure before raising it: the failure gives no clue at all.
22
- */
23
- const DEFAULT_WINDOW = 100;
24
-
25
- /**
26
- * How far the offset is rounded.
27
- *
28
- * Without it every scrolled pixel is a new question. Rounding means the
29
- * subscription only moves when the view has genuinely left what it was reading.
30
- */
31
- const BLOCK = 50;
32
-
33
- /**
34
- * How close the view may come to an edge before the window is moved.
35
- *
36
- * The hysteresis is what keeps this from running away: every publication makes
37
- * the list longer, the viewport recalculates and emits a range, and recentring
38
- * on each of those re-subscribes - which republishes, which emits again.
39
- */
40
- const MARGIN = 10;
41
-
42
- /**
43
- * How long a row that just changed stays marked.
44
- *
45
- * The `.fresh` styling on the consuming screen should run for exactly this
46
- * long. Shorter here cuts the animation off mid-way; longer leaves the row
47
- * plain while it is still marked.
48
- */
49
- const FRESH_MS = 1000;
50
-
51
- /**
52
- * One live window of a long list, as a CDK data source.
53
- *
54
- * The screen watches one thing: the rows around what it is showing. Scroll and
55
- * the window moves; something changes and the server pushes what that window
56
- * now holds. There is no page cache and no second question in flight - the
57
- * window *is* the question, which is what lets a paged list be pushed at all.
58
- *
59
- * The array handed to the viewport is the full length the server reports, with
60
- * a hole wherever the window does not reach. That is what makes the scrollbar
61
- * tell the truth from the first frame: its height is the whole list, not the
62
- * part being watched.
63
- */
64
- export class LiveWindowDataSource<Row extends LiveRow> extends DataSource<Row | undefined> {
65
- private readonly published = new BehaviorSubject<(Row | undefined)[]>([]);
66
- private readonly viewing = new Subscription();
67
- private readonly stamp = signal(0);
68
-
69
- /**
70
- * Bumped on every publication, and meant to be read in the template.
71
- *
72
- * Zoneless applications schedule nothing when a row arrives from a socket
73
- * callback: the table is told its data changed but no pass is ever run, and
74
- * the screen holds stale rows until something unrelated wakes Angular up.
75
- *
76
- * Two ways to say it properly, and this is the one that needs nothing from
77
- * the caller: a signal the view reads. Hand a `ChangeDetectorRef` to the
78
- * constructor instead and the repaint is asked for here, leaving the template
79
- * to say only what it shows. (`ApplicationRef.tick()` is the third way and the
80
- * wrong one - it throws when it lands inside a cycle already in progress.)
81
- */
82
- readonly revision = this.stamp.asReadonly();
83
-
84
- private list = new LiveList<Row>();
85
- private watching: Subscription | null = null;
86
-
87
- /** The rows a patch touched a moment ago - see `fresh`. */
88
- private readonly recent = new Set<string>();
89
-
90
- /** Where the current subscription starts. Its length is always `window`. */
91
- private offset = 0;
92
-
93
- private open: ((offset: number, limit: number) => Observable<UpdateFrame<Row>>) | null = null;
94
- private range = { start: 0, end: 0 };
95
-
96
- constructor(
97
- private readonly onTotal: (total: number) => void = () => undefined,
98
- /** Told when a patch cannot be applied, so the caller can ask again. */
99
- private readonly onDrift: () => void = () => undefined,
100
- /** Rows per window - see `DEFAULT_WINDOW` for how to choose one. */
101
- private readonly window: number = DEFAULT_WINDOW,
102
- /**
103
- * The view to repaint when something arrives. Optional, and the difference
104
- * it makes is on the screen's side, not here.
105
- *
106
- * `markForCheck()` marks the view dirty *and* notifies the zoneless
107
- * scheduler, so a frame landing in a socket callback gets a pass run for it.
108
- * Given one, a template needs no `revision()`; given none, it does.
109
- *
110
- * ```ts
111
- * readonly source = new LiveWindowDataSource<Row>(
112
- * (total) => this.total.set(total),
113
- * () => this.topic.resync(),
114
- * 100,
115
- * inject(ChangeDetectorRef),
116
- * );
117
- * ```
118
- */
119
- private readonly repaint?: ChangeDetectorRef,
120
- ) {
121
- super();
122
- }
123
-
124
- connect(viewer: CollectionViewer): Observable<(Row | undefined)[]> {
125
- // Kept because a data source is asked for it, but not relied on: inside a
126
- // `mat-table` the viewer is the table, whose `viewChange` stays silent
127
- // while the CDK viewport does the scrolling. `track` is what actually
128
- // reports where the eye is.
129
- this.viewing.add(viewer.viewChange.subscribe((range) => this.moveTo(range)));
130
- return this.published;
131
- }
132
-
133
- /**
134
- * Follows a viewport's rendered range.
135
- *
136
- * The screen hands this over explicitly because the `CollectionViewer` a
137
- * table passes to `connect` does not carry it. Without this the window stays
138
- * where it started and everything below the first screen is a placeholder
139
- * that never fills.
140
- */
141
- track(ranges: Observable<ListRange>): void {
142
- this.viewing.add(ranges.subscribe((range) => this.moveTo(range)));
143
- }
144
-
145
- disconnect(): void {
146
- this.viewing.unsubscribe();
147
- this.watching?.unsubscribe();
148
- }
149
-
150
- /** How long the list is, as the server last reported it. */
151
- get length(): number {
152
- return this.list.total();
153
- }
154
-
155
- /**
156
- * The index the server pointed at, in the whole list rather than in the page.
157
- *
158
- * Whatever it means is the screen's business. It survives the window moving,
159
- * which is the point: a boundary the reader has scrolled away from is still
160
- * where it was.
161
- */
162
- get pivot(): number | null {
163
- return this.list.pivot();
164
- }
165
-
166
- /** Every republication, for a caller waiting on one row rather than on the viewport. */
167
- get changes(): Observable<(Row | undefined)[]> {
168
- return this.published.asObservable();
169
- }
170
-
171
- /** The row at that index, when the window reaches it. */
172
- at(index: number): Row | undefined {
173
- return this.published.value[index];
174
- }
175
-
176
- /**
177
- * Whether this row arrived, or changed, a moment ago.
178
- *
179
- * Only patches mark anything: a snapshot is the answer to "what does this
180
- * window hold", which is what arriving on the screen and what scrolling both
181
- * ask, and lighting up a whole page every time the window moves says nothing.
182
- *
183
- * A patch's `upserted` is exactly the rows whose version changed, so a row
184
- * that merely shifted because three arrived above it is not marked. The one
185
- * approximation: for a window part-way down the list, a row pushed into it
186
- * from just outside is new to this client without being new to the list.
187
- */
188
- fresh(id: string | undefined): boolean {
189
- return id !== undefined && this.recent.has(id);
190
- }
191
-
192
- /**
193
- * Starts again on a new question.
194
- *
195
- * A different question has a different answer, and a row kept from the
196
- * previous one would be an answer to neither.
197
- */
198
- reset(open: (offset: number, limit: number) => Observable<UpdateFrame<Row>>): void {
199
- this.open = open;
200
- this.range = { start: 0, end: BLOCK };
201
- this.offset = -1;
202
- this.list = new LiveList<Row>();
203
- this.recent.clear();
204
- this.published.next([]);
205
- // What is on the screen has just become the answer to a question nobody is
206
- // asking any more, and the snapshot lands a moment later. Emptying it
207
- // without saying so leaves the previous answer on display in between.
208
- //
209
- // `markForCheck` and not `touched`: a screen calls this from an `effect`,
210
- // and Angular 18 - which this package still supports - refuses a signal
211
- // write from inside one.
212
- this.repaint?.markForCheck();
213
- this.follow();
214
- }
215
-
216
- /**
217
- * Makes sure the window covers one row, wherever the viewport currently is.
218
- *
219
- * Stepping through a detail panel walks past the edge of what is loaded, and
220
- * the scroll that follows only reports where it lands - too late for the row
221
- * the panel is already opening on.
222
- */
223
- ensure(index: number): void {
224
- if (index >= this.offset && index < this.offset + this.window) {
225
- return;
226
- }
227
- // The offset is computed here rather than through `range`: that field is
228
- // where the viewport is, and writing a made-up position into it means the
229
- // next real range disagrees, moves the window back, and the two take turns
230
- // until the renderer gives up.
231
- //
232
- // Clamped the way `follow` clamps, and for the same reason: rounding to a
233
- // block can land beside the very row that was asked for.
234
- const centred = Math.round((index - this.window / 2) / BLOCK) * BLOCK;
235
- const wanted = Math.max(0, Math.min(index, Math.max(centred, index - this.window + 1)));
236
- if (wanted === this.offset) {
237
- return;
238
- }
239
- this.offset = wanted;
240
- this.subscribe();
241
- }
242
-
243
- private moveTo(range: ListRange): void {
244
- // An empty range says nothing about where the eye is, and taking it at face
245
- // value moves the window to the top of the list. A viewport emits one every
246
- // time it is hidden or resized to nothing - which is what opening a drawer
247
- // over it does, and why the list behind came back blank.
248
- if (range.end <= range.start) {
249
- return;
250
- }
251
- this.range = range;
252
- this.follow();
253
- }
254
-
255
- /** Moves the window if the view has walked out of what it covers. */
256
- private follow(): void {
257
- if (!this.open) {
258
- return;
259
- }
260
- const { start, end } = this.range;
261
-
262
- // What is left once the rendered rows are covered, and therefore how much
263
- // of it can be spent as hysteresis on each side. Asking for the full MARGIN
264
- // regardless leaves a band of rows loaded by nothing: a window barely wider
265
- // than the viewport cannot both cover it and keep ten rows in hand.
266
- const spare = Math.max(0, this.window - (end - start));
267
- const margin = Math.min(MARGIN, Math.floor(spare / 2));
268
- if (this.offset >= 0 && start >= this.offset + margin && end <= this.offset + this.window - margin) {
269
- return;
270
- }
271
-
272
- // Centred on the view and rounded to a block - then pulled back until it
273
- // covers the rendered rows. Covering them is the requirement; the block is
274
- // only a way of not moving on every scrolled pixel, and rounding to one is
275
- // exactly how a window settles beside the rows it was meant to hold:
276
- // rendered [90, 120) rounded to [100, 150), leaving 90 to 99 in no window
277
- // at all - and, the offset being unchanged, leaving them there.
278
- const middle = (start + end) / 2;
279
- const centred = Math.round((middle - this.window / 2) / BLOCK) * BLOCK;
280
- // Never past the first rendered row, never so far back that the last one
281
- // falls out. When the viewport renders more rows than the window holds
282
- // there is no such position: the first row wins, which keeps the hole below
283
- // the fold rather than above it.
284
- const wanted = Math.max(0, Math.min(start, Math.max(centred, end - this.window)));
285
- if (wanted === this.offset) {
286
- return;
287
- }
288
- this.offset = wanted;
289
- this.subscribe();
290
- }
291
-
292
- private subscribe(): void {
293
- if (!this.open) {
294
- return;
295
- }
296
- this.watching?.unsubscribe();
297
- // A fresh list per subscription: the server answers a new window with a
298
- // snapshot, and rows from the previous one are at different offsets. The
299
- // marks go with them - they belonged to the window being left.
300
- this.list = new LiveList<Row>();
301
- this.recent.clear();
302
- this.watching = this.open(this.offset, this.window).subscribe({
303
- next: (update) => {
304
- if (!this.list.apply(update)) {
305
- this.onDrift();
306
- return;
307
- }
308
- if (update.type === 'patch') {
309
- this.mark(update.upserted.map((row) => row.id));
310
- }
311
- this.onTotal(this.list.total());
312
- this.publish();
313
- },
314
- error: (error: unknown) => console.error('[livewire] window failed', error),
315
- });
316
- }
317
-
318
- private mark(ids: string[]): void {
319
- if (ids.length === 0) {
320
- return;
321
- }
322
- for (const id of ids) {
323
- this.recent.add(id);
324
- }
325
- // One timer per wave, clearing its own ids: a single shared timer would be
326
- // pushed back by every new arrival, so under a busy feed nothing would ever
327
- // stop being marked. The repaint is explicit because a zoneless application
328
- // schedules nothing for a set mutated outside the view.
329
- setTimeout(() => {
330
- for (const id of ids) {
331
- this.recent.delete(id);
332
- }
333
- this.touched();
334
- }, FRESH_MS);
335
- }
336
-
337
- /**
338
- * The whole length, holes and all.
339
- *
340
- * A new array each time: the viewport compares references to know something
341
- * changed, and the rows themselves are shared rather than copied.
342
- */
343
- private publish(): void {
344
- const rows = new Array<Row | undefined>(this.list.total());
345
- const held = this.list.rows();
346
- for (let index = 0; index < held.length; index += 1) {
347
- rows[this.offset + index] = held[index];
348
- }
349
- this.published.next(rows);
350
- this.touched();
351
- }
352
-
353
- /**
354
- * Says that the screen has something new to show.
355
- *
356
- * Both ways at once, and they do not overlap: the signal serves a template
357
- * that reads `revision()`, and `markForCheck()` serves one that does not.
358
- * Whichever the screen uses, the other costs a counter.
359
- */
360
- private touched(): void {
361
- this.stamp.update((count) => count + 1);
362
- this.repaint?.markForCheck();
363
- }
364
- }