Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server)!: redesign callable ability #78

Merged
merged 14 commits into from
Jan 11, 2025
Merged

feat(server)!: redesign callable ability #78

merged 14 commits into from
Jan 11, 2025

Conversation

unnoq
Copy link
Owner

@unnoq unnoq commented Jan 11, 2025

🚨 Breaking Changes Alert 🚨

  • procedure is now completely non-callable by default (use the new .callable or .actionable methods for that).
  • createProcedureClient and createRouterClient now accept two arguments instead of one as before.

🚀 New Features 🚀

  • New .callable method to make a procedure callable like a regular function.
  • New .actionable method, similar to .callable(), but type-compatible with server actions (yes, server actions work again).
  • New call() helper function to directly call any procedure without creating a client.
'use server'

import { os } from '@orpc/server'
import { z } from 'zod'

export const getting = os
  .input(z.object({
    name: z.string(),
  }))
  .output(z.string())
  .handler(async ({ input }) => {
    return `Hello ${input.name}`
  })
  .actionable()

// from client just call it as a function
const onClick = async () => {
  const result = await getting({ name: 'Unnoq' })
  alert(result)
}

Copy link

vercel bot commented Jan 11, 2025

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

Name Status Preview Comments Updated (UTC)
orpc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 11, 2025 8:39am

Copy link

pkg-pr-new bot commented Jan 11, 2025

Open in Stackblitz

More templates

@orpc/client

npm i https://pkg.pr.new/@orpc/client@78

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@78

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@78

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@78

@orpc/server

npm i https://pkg.pr.new/@orpc/server@78

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@78

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@78

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@78

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@78

commit: 59bd6a6

@unnoq unnoq merged commit 23aa4be into main Jan 11, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant