htmx
htmx copied to clipboard
Add events to WebSocket extension
Current implementation of websockets provides no event support for events which really limits possible use-cases for the extension. There already were PRs (#1099, #435), that could be covered by events just fine
This issue tracks the effort to implement a number of events, covering all major steps of websockets lifecycle and message processing.
Namely, the following events are proposed:
htmx:wsOpenraised when websocket is connected to the remote endpointhtmx:wsCloseraised when websocket connection is closed normallyhtmx:wsErrorraised when websocket onerror event is raisedhtmx:wsMessageraised when websocket has received a message before any processing startshtmx:wsAfterMessageraised when message processing has been completedhtmx:wsConfigMessageraised during message building pipeline as a way to modify message content from JS akin tohtmx:configRequesthtmx:wsBeforeSendraised right before sending message to remote endpointhtmx:wsAfterSendraised after message has been sent
The events must also provide a way to interact with underlying websocket in case event handler needs to send some message from JS
This issue continues from #699