tRPCttRPC
Powered by
p6l.richardP
tRPC•3y ago•
7 replies
p6l.richard

How can I use `onSettled` in the `experimental_createTRPCNextAppDirClient`?

Context

I want to migrate the following trpc/client hook to the experimental version
const searchMandate = api.mandate.search.useMutation({
    onSettled: (data) => {
      searchQueryMethods.reset();
      data?.length
        ? toast.success(`Found ${data?.length} companies.`)
        : toast.message("No companies found.");
    },
  });
const searchMandate = api.mandate.search.useMutation({
    onSettled: (data) => {
      searchQueryMethods.reset();
      data?.length
        ? toast.success(`Found ${data?.length} companies.`)
        : toast.message("No companies found.");
    },
  });


However, the
experimental_createTRPCNextAppDirClient
experimental_createTRPCNextAppDirClient
exposes the
mutation
mutation
directly, not the
useMutation
useMutation
anymore



Problem
- the
ClientContext
ClientContext
from the
ProcedureArgs
ProcedureArgs
doesn't seem to accept any callback configuration? (the
...args
...args
type for the
mutation
mutation
on the consumer is
any
any
but I assume it's still the actual type)
- checking the trpc example I see it show cases a
mutation
mutation
without any callback configs (https://github.com/trpc/trpc/blob/cf5783bebbec295db84ec7b5dafa33da114379ad/examples/.experimental/next-app-dir/src/app/post-example/page.tsx)
- I also peeked at @julius's awesome acme-corp but it's similar to the trpc example in that it doesn't make use of callbacks.

version:
"@trpc/client": "11.0.0-alpha-next-2023-11-01-15-02-16.94"
"@trpc/client": "11.0.0-alpha-next-2023-11-01-15-02-16.94"
CleanShot_2023-11-03_at_13.10.212x.png
CleanShot_2023-11-03_at_13.08.462x.png
GitHub
trpc/examples/.experimental/next-app-dir/src/app/post-example/page....
🧙‍♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy. - trpc/trpc
trpc/examples/.experimental/next-app-dir/src/app/post-example/page....
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

How can I enable experimental Suspense on NextJS
gwilliamnnGgwilliamnn / ❓-help
3y ago
How can i use inferprocedureoutput?
functiondjFfunctiondj / ❓-help
3y ago
middleware executed twice? should i use `experimental_standaloneMiddleware`?
y_nkYy_nk / ❓-help
7mo ago
Can i use try/catch in procedures?
Answer OverflowAAnswer Overflow / ❓-help
3y ago