Skip to content

rewrite subscriptions with observables - #1784

Merged
KATT merged 16 commits into
nextfrom
sachinraja/observable-subscription
Apr 25, 2022
Merged

KATT merged 16 commits into
nextfrom
sachinraja/observable-subscription

Conversation

@sachinraja

@sachinraja sachinraja commented Apr 14, 2022 •

Copy link
Copy Markdown
Member

closes #1596
part of #1597

new API:

.subscription('onAdd', {
  resolve() {
    return observable<Post>((emit) => {
      const onAdd = (data: Post) => emit.next(data);
      ee.on('add', onAdd);

      return () => {
        ee.off('add', onAdd);
      };
    });
  },
})

This should allow tRPC to be used in most (all?) JS runtimes.

  • observable moved to server (@trpc/client/observable -> @trpc/server/observable)

I'm not sure how observable can replace EventEmitter in the examples so would appreciate some help with that.

@vercel

vercel Bot commented Apr 14, 2022 •

Copy link
Copy Markdown

@sachinraja
sachinraja changed the base branch from main to next April 14, 2022 04:30
Comment thread packages/server/src/adapters/ws.ts Resolved
Comment thread packages/server/test/websockets.test.ts Resolved
@vercel

vercel Bot commented Apr 16, 2022 •

Copy link
Copy Markdown

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

Name Status Preview Updated
next-prisma-starter ✅ Ready (Inspect) Visit Preview Apr 25, 2022 at 0:52AM (UTC)
www ✅ Ready (Inspect) Visit Preview Apr 25, 2022 at 0:52AM (UTC)

@jlalmes jlalmes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM - Good job @sachinraja 🎉

Comment thread www/docs/further/subscriptions.md Resolved
Comment thread www/docs/further/subscriptions.md Resolved

@KATT KATT 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.

Thank you both, your help means a lot to me!

@github-actions

github-actions Bot commented Oct 6, 2022

Copy link
Copy Markdown
Contributor

This pull request has been locked because it had no new activity for 30 days. If you think, this PR is still necessary, create a new one with the same branch. Thank you.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 6, 2022

This branch was successfully deployed

3 active deployments
Preview – next-prisma-starter — aa41dee6 Deployed Apr 25, 2022 by vercel[bot]
Preview – todomvc — aa41dee6 Deployed Apr 25, 2022 by vercel[bot]
Preview – www — aa41dee6 Deployed Apr 25, 2022 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decouple @trpc/server from node Rewrite subscriptions with new observables

3 participants