@panphora/clayjs 0.7.1 → 0.7.2
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/package.json +1 -1
- package/src/plugins/wire.js +9 -3
package/package.json
CHANGED
package/src/plugins/wire.js
CHANGED
|
@@ -105,11 +105,17 @@ function view(rec) {
|
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
// The second argument is the inbound frame that caused this emit, when one did,
|
|
109
|
+
// and null otherwise. Today only `wire/status` passes it, which is the one case
|
|
110
|
+
// a snapshot cannot describe on its own: `rec.text` is sticky across later
|
|
111
|
+
// states, so a listener accumulating status lines has no other way to tell a new
|
|
112
|
+
// line from the same line arriving again under a new state. Terminal outcomes
|
|
113
|
+
// need no frame, since `handle.done` settles for every one of them.
|
|
114
|
+
function emit(rec, frame) {
|
|
109
115
|
const snapshot = view(rec);
|
|
110
116
|
for (const fn of listeners) {
|
|
111
117
|
try {
|
|
112
|
-
fn(snapshot);
|
|
118
|
+
fn(snapshot, frame || null);
|
|
113
119
|
} catch (err) {
|
|
114
120
|
console.error("clay.wire: a listener threw", err);
|
|
115
121
|
}
|
|
@@ -223,7 +229,7 @@ function handleFrame(frame) {
|
|
|
223
229
|
arm(rec, SILENCE_TIMEOUT_MS, "the agent stopped responding");
|
|
224
230
|
rec.text = typeof frame.text === "string" ? frame.text : "";
|
|
225
231
|
rec.state = "acked";
|
|
226
|
-
emit(rec);
|
|
232
|
+
emit(rec, frame);
|
|
227
233
|
break;
|
|
228
234
|
case "wire/done":
|
|
229
235
|
land(rec);
|