Skip to content

Commit 7de741c

Browse files
committed
use custom create-websocket
1 parent b805631 commit 7de741c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

web_src/js/htmx.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ document.body.addEventListener('htmx:responseError', (event) => {
2121
showErrorToast(`Error ${event.detail.xhr.status} when calling ${event.detail.requestConfig.path}`);
2222
});
2323

24+
// eslint-disable-next-line no-import-assign
25+
htmx.createWebSocket = (url) => {
26+
// TODO: reuse websocket from shared webworker
27+
const sock = new WebSocket(url, []);
28+
sock.binaryType = htmx.config.wsBinaryType;
29+
return sock;
30+
};
2431
document.body.addEventListener('htmx:wsOpen', (evt) => {
2532
const socket = evt.detail.socketWrapper;
2633
socket.send(JSON.stringify({action: 'subscribe', data: {url: window.location.href}}));

0 commit comments

Comments
 (0)