feldroy / feldroy/air

FEAT: Make SSE easier

Open
#911 1 comment 0 reactions 0 assignees View on GitHub
Air Tags feature: core feature: extra python
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.