You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: website/docs/getting-started.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -47,8 +47,8 @@ This is a basic client, without any options or middleware functions. If you want
47
47
48
48
### 2. Define a new action
49
49
50
-
This is how a safe action is created. Providing a validation input schema to the function via `schema()`, we're sure that data that comes in is type safe and validated.
51
-
The `define()` method lets you define what happens on the server when the action is called from client, via an async function that receives the parsed input and context as arguments. In short, this is your _server code_. **It never runs on the client**:
50
+
This is how a safe action is created. Providing a validation input schema to the function via [`schema()`](docs/safe-action-client/instance-methods#schema), we're sure that data that comes in is type safe and validated.
51
+
The [`action()`](/docs/safe-action-client/instance-methods#action) method lets you define what happens on the server when the action is called from client, via an async function that receives the parsed input and context as arguments. In short, this is your _server code_. **It never runs on the client**:
`metadata` expects an object of type [`ActionMetadata`](/docs/types#actionmetadata) that lets you specify useful data about the safe action you're defining, and it returns the [`schema`](#schema) method, since metadata is action specific and not shared with other actions. As of now, the only data you can pass in is the `actionName`, but that could be extended in the future. You can then access it in the `middlewareFn` passed to [`use`](#use) and in [`serverCodeFn`](#servercodefn) passed to [`define`](#define).
32
+
`metadata` expects an object of type [`ActionMetadata`](/docs/types#actionmetadata) that lets you specify useful data about the safe action you're defining, and it returns the [`schema`](#schema) method, since metadata is action specific and not shared with other actions. As of now, the only data you can pass in is the `actionName`, but that could be extended in the future. You can then access it in the `middlewareFn` passed to [`use`](#use) and in [`serverCodeFn`](#servercodefn) passed to [`action`](#action).
`schema` accepts an input schema of type `Schema` (from TypeSchema), which is used to define the arguments that the safe action will receive, and returns the [`define`](#define) and [`bindArgsSchemas`](#bindargsschemas) methods, which allows you, respectively, to define a new action using that input schema or extend the arguments with additional bound ones.
40
+
`schema` accepts an input schema of type `Schema` (from TypeSchema), which is used to define the arguments that the safe action will receive, and returns the [`action`](#action) and [`bindArgsSchemas`](#bindargsschemas) methods, which allows you, respectively, to define a new action using that input schema or extend the arguments with additional bound ones.
`bindArgsSchemas` accepts an array of bind input schemas of type `Schema` (from TypeSchema), which is used to define the bind arguments that the safe action will receive, and returns the [`define`](#define) method, which allows you, to define a new action using the input and bind inputs schemas.
48
+
`bindArgsSchemas` accepts an array of bind input schemas of type `Schema` (from TypeSchema), which is used to define the bind arguments that the safe action will receive, and returns the [`action`](#action) method, which allows you, to define a new action using the input and bind inputs schemas.
`define` is the final method in the list. It accepts a [`serverCodeFn`](#servercodefn) of type [`ServerCodeFn`](/docs/types#servercodefn) and returns a new safe action function of type [`SafeActionFn`](/docs/types#safeactionfn), which can be called from your components.
56
+
`action` is the final method in the list. It accepts a [`serverCodeFn`](#servercodefn) of type [`ServerCodeFn`](/docs/types#servercodefn) and returns a new safe action function of type [`SafeActionFn`](/docs/types#safeactionfn), which can be called from your components.
57
57
58
58
When the action is executed, all middleware functions in the chain will be called at runtime, in the order they were defined.
0 commit comments