analogjs / analog

The fullstack meta-framework for Angular. Powered by Vite and Nitro
https://analogjs.org
MIT License
2.5k stars 240 forks source link

Feature: RxJS based tRPC client #379

Closed Dafnik closed 1 year ago

Dafnik commented 1 year ago

Which scope/s are relevant/related to the feature request?

trpc

Information

Add a RxJS compatible trpc-client to analogjs.

I would like to contribute the functionality of ngx-trpc to Analog's trpc implementation.

@goetzrobin pointed out on reddit [thread] that it would be a good fit and I also think that you would get the most benefit out of ngx-trpc by using it in a meta framework like Analog.

Before starting with the implementation I would like get feedback on a few things.

  1. tRPC client websocket subscribe trpc-client subscribe method for subscribing to websockets is currently not supported. Would this be required?

  2. some bugs to fix I still get some warning running the custom trpc client and would like to ask you if you have any ideas fixing this. Here is an startet example with the error. https://github.com/Dafnik/ngx-trpc-nx-fastify-example

When all questions are cleared I can start creating a pull request.

If you have any other thoughts or questions just hit me up.

Cheers!

Describe any alternatives/workarounds you're currently using

No response

I would be willing to submit a PR to fix this issue

Cross-referencing: #197

goetzrobin commented 1 year ago

Right now it relies on a hard coded httpBatchLink, so no web socket support is definitely not a blocker.

In regards to the bugs, I would suggest to create a branch with the implementation and we can work through them during the code review process? That way we already have the code in the analog context and within the repository, which should make it a little easier to debug.

That's what I am thinking at least! @brandonroberts what do you think?

brandonroberts commented 1 year ago

Cool project! That sounds good to me. We should consider support/integration for Angular Signals also for the future.

goetzrobin commented 1 year ago

Thats a really good point! I would love something like the react hooks DX provided by tRPC directly. Maybe something like the suspensify method described in this article would be cool? https://marmicode.io/blog/managing-rxjs-traffic-with-signals

Dafnik commented 1 year ago

Sounds good to me @goetzrobin. I will start implementing a pr.

yeah. good point @brandonroberts. This would probably be a second client.

suspensify looks great, but do we want this in both, the rxjs and signal client?