vishalbalaji / trpc-svelte-query-adapter

A simple adapter to use `@tanstack/svelte-query` with trpc, similar to `@trpc/react-query`.
71 stars 6 forks source link

Support for cancelling queries? #17

Closed PickleyD closed 8 months ago

PickleyD commented 9 months ago

Firstly, thanks so much for making this adapter.

I'm trying to cancel a query but I'm not observing any effect from my attempts. Reading the trpc docs for the 'useQuery' function, they mention needing to set 'abortOnUnmount' to true, but I can't find a way to set this using this adapter. Am I missing something?

Anyone have a working example they can share? 🙏

vishalbalaji commented 9 months ago

Hi @PickleyD, glad you found this library useful.

As of now, I haven't been able to implement query cancellation, but I'll add that to my checklist. Thanks for pointing it out!

I am currently away on a work trip and will mostly be able to look into it by the end of next week or so. In the meantime, if possible, it would be really helpful if there was a small reproduction on StackBlitz or something that I could go off of.

vishalbalaji commented 8 months ago

Hi @PickleyD, v2.2.1 has been pushed which now handles query cancellation. You can enable this globally by passing in aboutOnUnmount to svelteQueryWrapper or on a per-query basis by passing trpc: { abortOnUnmount: true } to the query's options. Hope this resolves the issue.

PickleyD commented 8 months ago

Great! Thanks for this. I will try it out soon and let you know how I get on