@danxbot/ui 7.9.6 → 7.9.8
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.
- package/dist/index.js +24 -8
- package/dist/index.js.map +1 -1
- package/dist/types/lib/reads/slots.d.ts +28 -0
- package/package.json +1 -1
|
@@ -44,6 +44,28 @@ export declare function slotPendingKeys(id: string): readonly string[];
|
|
|
44
44
|
* inserts at a guessed index renders a list that is subtly, confidently wrong.
|
|
45
45
|
*
|
|
46
46
|
* AND ONLY WHERE IT BELONGS — see `belongsTo`.
|
|
47
|
+
*
|
|
48
|
+
* ==== HELD BACK WHILE AN OPTIMISTIC CREATE OF THIS TYPE IS OUTSTANDING (SG-982) ====
|
|
49
|
+
*
|
|
50
|
+
* A row the reader just created optimistically has a TEMPORARY key here — the request that will
|
|
51
|
+
* tell this slot the real one is still in flight. If the server's own `created` broadcast for
|
|
52
|
+
* that same row reaches this client before that request answers (observed: the broadcast can
|
|
53
|
+
* easily win the race against the reader's own round trip), it names the REAL key, which this
|
|
54
|
+
* function cannot recognise as "the row already shown" — the two keys share no characters. Adding
|
|
55
|
+
* it to `pending` right away would render it as a second row beside the optimistic one for
|
|
56
|
+
* however long the request takes to settle, which is exactly the transient duplicate this guards
|
|
57
|
+
* against.
|
|
58
|
+
*
|
|
59
|
+
* So while ANY optimistic create for this slot's type is outstanding (`optimisticHead` /
|
|
60
|
+
* `optimisticTail` non-empty), an incoming `created` key is parked in `awaitingSettle` instead —
|
|
61
|
+
* neither rendered nor counted — and `settleOptimisticMember` flushes it into `pending` the
|
|
62
|
+
* instant the slot has no outstanding optimistic create left. If the parked key turns out to BE
|
|
63
|
+
* the reader's own row, `settleOptimisticMember` already removes it before the flush ever runs
|
|
64
|
+
* (see its own doc); if it turns out to be someone else's genuinely new row, it reaches `pending`
|
|
65
|
+
* moments later, no worse than it would have anyway.
|
|
66
|
+
*
|
|
67
|
+
* This never suppresses a `created` broadcast outright, and it applies only during a real,
|
|
68
|
+
* in-progress race — not a guess about which rows might collide, and not a fixed delay.
|
|
47
69
|
*/
|
|
48
70
|
export declare function appendCreated(event: RealtimeEvent): void;
|
|
49
71
|
/** What a create's `lists` predicate is shown about each live slot. */
|
|
@@ -74,6 +96,12 @@ export declare function addOptimisticMember(key: string, type: string, lists: ((
|
|
|
74
96
|
* An optimistic create has settled. With `realKey` (the server answered), the real row takes
|
|
75
97
|
* the pending row's place — in the fetched page, so it stays put until the server next orders
|
|
76
98
|
* the list. With `null` (the create failed), the pending row simply goes.
|
|
99
|
+
*
|
|
100
|
+
* ALSO THE FLUSH POINT FOR `awaitingSettle` (SG-982): once this slot has no outstanding
|
|
101
|
+
* optimistic create left, any `created` broadcasts `appendCreated` held back while this one was
|
|
102
|
+
* in flight are released into `pending` — the race they were parked for is over. `realKey` itself
|
|
103
|
+
* is removed from that queue first: if it is the reader's own echo, it has just been folded
|
|
104
|
+
* straight into `keys` above and must never also reach `pending` as a second copy.
|
|
77
105
|
*/
|
|
78
106
|
export declare function settleOptimisticMember(tempKey: string, realKey: string | null): void;
|
|
79
107
|
export declare function subscribeToSlot(id: string, listener: () => void): () => void;
|