FEAT: Make SSE easier
- Dominant language
- Python
- Stars
- 917
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
There is friction when using SSE with Air. While we have a good SSEResponse for the backend, the client remains obtuse. Per https://htmx.org/extensions/sse/ you have to:
1. Use an `air.Script` to import the SSE extension to match this HTML spec:
```python
```
2. The tag to be modified then has to have these controls
```html
sse-connect="/chatroom"
sse-swap="message">
Contents of this box will be updated in real time
with every SSE message received from the chatroom.
```
**Describe the feature**
Some kind of wrapper around all of the above would be useful. Something like this might be the way:
```python
air.Div(
# The following line would:
# prepend the current tag with the SSE import:
#
# and would generate these attributes:
# hx-ext="sse"
# sse-connect="/chatroom"
sse="/chatroom",
# Generates a hx-swap attribute per the SSE extention docs
sse_swap=""
)
```
Contributor guide
Research direction
Start by reviewing the existing SSEResponse and air.Script APIs, then compare the proposed air.Div usage with the linked htmx SSE extension requirements. Done means agreeing on and implementing a wrapper that covers the SSE import and connection, extension, and swap attributes described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- html, python
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100