Skip to content

Create a specific ServerSentEventGenerator version that matches the w…#43

Closed
andredias wants to merge 1 commit intostarfederation:developfrom
andredias:develop
Closed

Create a specific ServerSentEventGenerator version that matches the w…#43
andredias wants to merge 1 commit intostarfederation:developfrom
andredias:develop

Conversation

@andredias
Copy link
Copy Markdown

This pull request creates a specific ServerSentEventGenerator version that matches the way FastAPI handles SSE since version 0.135

It doesn't break other versions.

@gazpachoking
Copy link
Copy Markdown
Collaborator

So, turns out you can already do this in the new FastAPI without this PR!

@app.get("/updates", response_class=DatastarResponse)
def updates():
    yield ServerSentEventGenerator.patch_elements("""<div id="myDiv"></div>""")

Should work out of the box. How do you feel about just recommending that way rather than rewriting how it works in the SDK to allow setting response_class=EventSourceResponse?

The bad news is that the datastar_response decorator is broken with the new fastapi versions. I'd like to find a way to fix that.

@gazpachoking
Copy link
Copy Markdown
Collaborator

I think given that DatastarResponse already works with the new fastapi generator based streaming there isn't a need to implement support for EventstreamResponse. I opened up #44 to remove the datastar_response decorator for fastapi and document the alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants