Skip to content

feat(server + client): add support for server-sent events (SSE) - #5713

Merged
KATT merged 347 commits into
nextfrom
05-10-subscriptions-sse
Jun 22, 2024
Merged

KATT merged 347 commits into
nextfrom
05-10-subscriptions-sse

Conversation

@KATT

@KATT KATT commented May 10, 2024 •

Copy link
Copy Markdown
Member

🎯 Changes

Adds a httpSubscriptionLink using server-sent events (SSE)

Docs: https://www-git-05-10-subscriptions-sse-trpc.vercel.app/docs/client/links/httpSubscriptionLink

✅ Checklist

  • I have followed the steps listed in the Contributing guide.
  • If necessary, I have added documentation related to the changes made.
  • I have added or updated the tests related to the changes made.

@vercel

vercel Bot commented May 10, 2024 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-prisma-starter ✅ Ready (Inspect) Visit Preview Jun 22, 2024 4:07pm
og-image ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 22, 2024 4:07pm
trpc-sse ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 22, 2024 4:07pm
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 22, 2024 4:07pm

Comment thread www/docs/community/awesome-trpc.mdx Resolved
juliusmarminge
juliusmarminge previously approved these changes Jun 12, 2024

@juliusmarminge juliusmarminge left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lots of unfamiliar stuff so my review should be taken lightly but couldn't find anything obvious that stands out

Comment on lines +114 to +119
yield {
id,
data: Object.keys(who).filter(
(user) => user !== opts.ctx.session?.user?.name,
),
} satisfies SSEvent;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you think about letting you yield anything and have a special function when you wanna yield SSEvent?

e.g.

yield { foo: "bar" }

then data would simply be "bar"

and doing eg

yield sseEvent({
  id: 1,
  foo: "bar",
})

if you wanna yield a "proper" SSE event

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that though instead of sseEvent, how about just sse or ssEvent or serverSentEvent?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, not bothered about the naming

@bnussman bnussman mentioned this pull request Jun 23, 2024
1 task done
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you.

This branch was successfully deployed

6 active (1 outdated) and 2 inactive (1 outdated) deployments
Preview – www — cf3a1cd1 Deployed Jun 22, 2024 by vercel[bot]
Preview – trpc-next-app-dir — cf3a1cd1 Deployed Jun 22, 2024 by vercel[bot]
Preview – next-prisma-starter — cf3a1cd1 Deployed Jun 22, 2024 by vercel[bot]
Preview – todomvc — cf3a1cd1 Deployed Jun 22, 2024 by vercel[bot]
Preview – og-image — cf3a1cd1 Deployed Jun 22, 2024 by vercel[bot]
production — cf3a1cd1 Deployed Jun 22, 2024 by railway-app[bot]
Production – trpc-sse — 9ee2d0b2 Deployed May 26, 2024 by vercel[bot]
production — f2f6394e Deployed May 16, 2024 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider SSE to enable server->client http subscriptions

7 participants