htmx icon indicating copy to clipboard operation
htmx copied to clipboard

SSE listen

Open wtpayne opened this issue 5 years ago • 8 comments

I made a little and slightly hacky change to support my SSE use-case. I'm not suggesting that this PR be merged... it's really just here for discussion.

wtpayne avatar Dec 12 '20 15:12 wtpayne

Record of the conversation from Discord:- [3:19 PM] wtpayne: Let me give the rationale. [3:19 PM] wtpayne: So ... I've got a dashboard builder. [3:19 PM] wtpayne: The dashboard components themselves can be dynamically added, removed and modified. [3:19 PM] wtpayne: For this, sse:swap is perfect. [3:20 PM] wtpayne: But I also want the dashboard components to display oscilloscope-like graphs... [3:20 PM] wtpayne: And for the data for the graph to come over as JSON, so I can use D3.js to do the plotting. [3:21 PM] wtpayne: So I have some situations where I want to do things the HTMX way ... and have a bit of HTML swapping in. [3:21 PM] wtpayne: And other situations where I want to do things differently, and have JSON coming in over SSE and being used to update a chart or other visualization with D3.js... [3:22 PM] wtpayne: So I need to be able to say 'do something with the content of this SSE event ... but don't swap it into the DOM'

wtpayne avatar Dec 12 '20 15:12 wtpayne

please retarget to dev branch as well, thank you for working on this!

Retargeted to 'dev' branch as requested.

wtpayne avatar Dec 12 '20 19:12 wtpayne

Added tests, and checked that tests pass.

wtpayne avatar Dec 12 '20 21:12 wtpayne

What's the status of this pull request? Is it ready for review?

1cg avatar Jan 02 '21 00:01 1cg

I think so. I've been using it like this without too many issue so far.

On Sat, 2 Jan 2021, 00:05 1cg, [email protected] wrote:

What's the status of this pull request? Is it ready for review?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/bigskysoftware/htmx/pull/263#issuecomment-753406999, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ53A3KDWRPZWMQWM7URSDSXZPLXANCNFSM4UYIFLDA .

wtpayne avatar Jan 02 '21 02:01 wtpayne

However... I did make a fix for what appeared to me to be a bug ... Settle wasn't being triggered, so I added it in. It seems to work, but I'm not sure 100% if it's the right thing to do.

On Sat, 2 Jan 2021, 02:15 William Payne, [email protected] wrote:

I think so. I've been using it like this without too many issue so far.

On Sat, 2 Jan 2021, 00:05 1cg, [email protected] wrote:

What's the status of this pull request? Is it ready for review?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/bigskysoftware/htmx/pull/263#issuecomment-753406999, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ53A3KDWRPZWMQWM7URSDSXZPLXANCNFSM4UYIFLDA .

wtpayne avatar Jan 02 '21 02:01 wtpayne

@benpate - I have a separate callback for each type of SSE event, and it would be exceedingly difficult to merge them together. (The callbacks are themselves transmitted over SSE) so my very strong preference would be to leave the SSE event name in the DOM event name if at all possible.

wtpayne avatar Jan 02 '21 02:01 wtpayne

resurrecting this thread: @benpate just pulled sse out to a separate extension and I'd like to revist this change in that context

1cg avatar Nov 23 '21 22:11 1cg

It looks like this is stalled out. It in the time since, Server-Side Events have been pulled out to an extension. If the current SSE extension still has the issue, feel free to either re-open this PR or make a new one and we'll get it looked at ASAP.

alexpetros avatar Nov 04 '23 18:11 alexpetros