bigskysoftware / htmx-extensions

167 stars 51 forks source link

Add hx-swap-oob capabilities to sse extension #94

Closed sopa0 closed 1 month ago

sopa0 commented 2 months ago

Hi!

Added hx-swap-oob functionality to the sse extension, + 2 tests cases that test for hx-swap-oob -> swaps correctly and hx-swap-oob + regular swap

Code is basically from the ws extension

Cheers

sopa0 commented 1 month ago

Matter of fact, after taking a look at the ws extension and its docs, it seems like it defaults to hx-swap-oob doesn't it? I'll push a few more changes, as here we'd need to support both hx-swap-oob properly and regular swaps

Telroshan commented 1 month ago

Oops, didn't mean to close this PR when deleting dev @sopa0 , I messed up, can you retarget to main ? 😆

sopa0 commented 1 month ago

haha don't worry, i'm going to create a new one with different logic anyway, I don't think straight up copying from the ws extension was the best move anyway

jaredweinfurtner commented 1 month ago

haha don't worry, i'm going to create a new one with different logic anyway, I don't think straight up copying from the ws extension was the best move anyway

@sopa0 what was the PR # for that?

sopa0 commented 1 month ago

haha don't worry, i'm going to create a new one with different logic anyway, I don't think straight up copying from the ws extension was the best move anyway

@sopa0 what was the PR # for that?

afaik the PR was actually not needed, I did some more testing and hx-swap-oob seems to work properly with hx-sse (using htmx 2.0.2 and htmx-ext-sse 2.2.2)

zanadoman commented 3 weeks ago

Hi! I'm interested in how you made hx-swap-oob to work with hx-sse, I have a problem where I want to swap different fragments with the data of sse events. The hx-trigger="sse:foo" hx-get="/foo" is too expensive for the backend I want to broadcast updates of different components from the server to the user with sse. In some cases I would need beforeend swaps or outterHtml swaps.