From 97a393fa1c9a342183ceaede9cd07564816bacce Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Tue, 30 Jan 2024 20:18:47 +0000 Subject: :bug: Fixed bug where ffi code incorrectly imported runtime. --- src/server-component.mjs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/server-component.mjs') diff --git a/src/server-component.mjs b/src/server-component.mjs index b7aec2c..373f4cd 100644 --- a/src/server-component.mjs +++ b/src/server-component.mjs @@ -63,22 +63,26 @@ export class LustreServerComponent extends HTMLElement { this.#socket?.close(); this.#socket = new WebSocket(`ws://${window.location.host}${route}`); - this.#socket.addEventListener("message", ({ data }) => { - const [kind, ...payload] = JSON.parse(data); + this.#socket.addEventListener("message", (message) => + this.messageReceivedCallback(message), + ); + } + } + } + } - switch (kind) { - case Constants.diff: - return this.diff(payload); + messageReceivedCallback({ data }) { + const [kind, ...payload] = JSON.parse(data); - case Constants.emit: - return this.emit(payload); + switch (kind) { + case Constants.diff: + return this.diff(payload); - case Constants.init: - return this.init(payload); - } - }); - } - } + case Constants.emit: + return this.emit(payload); + + case Constants.init: + return this.init(payload); } } @@ -107,7 +111,7 @@ export class LustreServerComponent extends HTMLElement { if (prev !== value) { this.#socket?.send( - JSON.stringify([Constants.attrs, [[attr, value]]]) + JSON.stringify([Constants.attrs, [[attr, value]]]), ); } }, -- cgit v1.2.3