ClientServerFn
A server function as the browser sees it: a function that returns a promise, plus the pieces a form or a tool may need.
A server function as the browser sees it: a function that returns a promise, plus the pieces a form or a tool may need.
Import#
ts
import type { ClientServerFn } from "@shadow-js/dusk/client";
Signature#
ts
interface ClientServerFn<Input = unknown, Output = unknown> {
/**
* Calls the function on the server. The argument is optional when `undefined` is a valid input,
* and required otherwise: the same rule as the server function this stub stands for. An optional
* last argument sets the options of this one call (`{ signal }` cancels the request), so a stub
* fits where a function `(input, { signal })` is expected, such as `submitWith` of
* `@shadow-js/forms`.
*/
(...input: [...CallArguments<Input>, options?: ServerFnCallOptions]): Promise<Output>;
/** The stable id of the function. */
readonly id: string;
/** The endpoint, for example `/_dusk/fn/q3Zr…`: use it as a form `action` for `form: true` functions. */
readonly url: string;
/** A version of the function with call options (abort signal, headers). */
with(options: ServerFnCallOptions): (...input: CallArguments<Input>) => Promise<Output>;
}
Members#
| Name | Type | Description |
|---|---|---|
Input |
Input = unknown |
|
Output |
Output = unknown |
|
id |
readonly id: string |
The stable id of the function. |
url |
readonly url: string |
The endpoint, for example /_dusk/fn/q3Zr…: use it as a form action for form: true functions. |
with |
with(options: ServerFnCallOptions): (...input: CallArguments<Input>) => Promise<Output> |
A version of the function with call options (abort signal, headers). |