Closed hayleigh-dot-dev closed 2 months ago
Enthusiastic noobs are welcome! how familiar are you with handling SSE in js in general?
@hayleigh-dot-dev decently familiar? I've used SSE in angular, elm, and vanilla js with backends in elixir, go, node, and python. That said, it's been a bit.
I think the main thing would be just adding a second attribute to the server-component.mjs for mode=“‘ws’ | ‘sse’” and then copying the ws implementation for handling incoming events. I think the main difference is the SSE version would probably only receive events and not emit any?
Thanks for the pointer. I looked at the code in that file and it seems to me that this is the Lustre analog of LiveView, is that right?
I suppose what I am interested in is not communicating DOM updates via SSE, but rather model updates. (I thought I'd create a RAG app to learn Lustre. And, to my naïve mind, I cannot see the value in SSE over WS for DOM updates.) Reading more through the docs, it seems like I likely want to be looking at the "custom effects". Is that right?
this is the Lustre analog of LiveView, is that right?
Yeah thats right.
but rather model updates.
In that case you'll write a custom effect thats right. You'll need to write the FFI code to work with fetch
yourself (there's a community package called lustre_http but it doesn't support SSE as far as I'm aware) and you'd dispatch a message on every event.
I'll close this for now, if you run into some questions feel free to drop into lustre's discord, ask in the gleam one, or open an issue here ^.^
Much thanks @hayleigh-dot-dev for your advice and also lustre.
Ahoy, I'm quite keen on this, though a lustre noob. Is there a realistic path to a noob contributing to this feature?