Skip to content

Rewrite subscriptions with new observables #1596

Closed

Description

@KATT

Related to #1592 / the next branch.

Now that we have rxjs added, we might want to use it for our subscription support.

Examples

Before

.subscription('onAdd', {
resolve() {
return new Subscription<Post>((emit) => {
const onAdd = (data: Post) => emit.data(data);
ee.on('add', onAdd);
return () => {
ee.off('add', onAdd);
};
});
},
})

After

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

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

The underlying event emitter in the example could also be observables:

interface MyEvents {
add: (data: Post) => void;
isTypingUpdate: () => void;
}
declare interface MyEventEmitter {
on<U extends keyof MyEvents>(event: U, listener: MyEvents[U]): this;
once<U extends keyof MyEvents>(event: U, listener: MyEvents[U]): this;
emit<U extends keyof MyEvents>(
event: U,
...args: Parameters<MyEvents[U]>
): boolean;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
class MyEventEmitter extends EventEmitter {}
const ee = new MyEventEmitter();

Activity

  1. added this to the milestone on Mar 6, 2022
  2. changed the title [-]Rewrite subscriptions with RxJS[/-] [+]Rewrite subscriptions with new observables[/+] on Mar 17, 2022
  3. john-schmitz commented on Mar 25, 2022

    @john-schmitz
    Contributor

    Just for context; why was the issue blocked?
    I'm very new to the repository and trcps internals

  4. sachinraja commented on Mar 25, 2022

    @sachinraja
    Member

    We were evaluating whether or not to use rxjs and decided not to (see discussion in #1592 for more details).

  5. KATT commented on Mar 26, 2022

    @KATT
    MemberAuthor

    Yeah, what @sachinraja said.

    Additionally, this would include moving the observables from @trpc/client/observables to server

  6. self-assigned this
    on Apr 4, 2022
  7. removed this from the milestone on Apr 11, 2022
  8. moved this from 🤔 Maybe / Nice to have to 🚧 In Progress in Roadmap and prioritieson Apr 20, 2022
  9. Repository owner moved this from 🚧 In Progress to ✅ Done in Roadmap and prioritieson Apr 30, 2022
  10. github-actions commented on Oct 4, 2022

    @github-actions
    Contributor

    This issue has been locked because it had no new activity for 14 days. If you are running into a similar issue, please create a new issue. Thank you.

  11. locked as resolved and limited conversation to collaborators on Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions