Skip to content

Commit af29ec2

Browse files
github-actions[bot]svelte-docs-bot[bot]Ocean-OS
authored
Sync kit docs (#1916)
sync kit docs Co-authored-by: svelte-docs-bot[bot] <196124396+svelte-docs-bot[bot]@users.noreply.github.com> Co-authored-by: ComputerGuy <[email protected]>
1 parent dcf848e commit af29ec2

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

apps/svelte.dev/content/docs/kit/20-core-concepts/60-remote-functions.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,22 @@ Because our form contains a `file` input, we've added an `enctype="multipart/for
393393
394394
In the case of `radio` and `checkbox` inputs that all belong to the same field, the `value` must be specified as a second argument to `.as(...)`:
395395
396+
```js
397+
/// file: constants.js
398+
export const operatingSystems = /** @type {const} */ (['windows', 'mac', 'linux']);
399+
export const languages = /** @type {const} */ (['html', 'css', 'js']);
400+
```
401+
396402
```js
397403
/// file: data.remote.js
404+
// @filename: constants.js
405+
export const operatingSystems = /** @type {const} */ (['windows', 'mac', 'linux']);
406+
export const languages = /** @type {const} */ (['html', 'css', 'js']);
407+
// @filename: index.js
398408
import * as v from 'valibot';
399409
import { form } from '$app/server';
400410
// ---cut---
401-
export const operatingSystems = /** @type {const} */ (['windows', 'mac', 'linux']);
402-
export const languages = /** @type {const} */ (['html', 'css', 'js']);
411+
import { operatingSystems, languages } from './constants';
403412

404413
export const survey = form(
405414
v.object({
@@ -705,10 +714,13 @@ We can customize what happens when the form is submitted with the `enhance` meth
705714

706715
<form {...createPost.enhance(async ({ form, data, submit }) => {
707716
try {
708-
await submit();
709-
form.reset();
717+
if (await submit()) {
718+
form.reset();
710719

711-
showToast('Successfully published!');
720+
showToast('Successfully published!');
721+
} else {
722+
showToast('Invalid data!');
723+
}
712724
} catch (error) {
713725
showToast('Oh no! Something went wrong');
714726
}

apps/svelte.dev/content/docs/kit/98-reference/[email protected]

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2428,12 +2428,12 @@ type RemoteForm<
24282428
callback: (opts: {
24292429
form: HTMLFormElement;
24302430
data: Input;
2431-
submit: () => Promise<void> & {
2431+
submit: () => Promise<boolean> & {
24322432
updates: (
24332433
...updates: RemoteQueryUpdate[]
2434-
) => Promise<void>;
2434+
) => Promise<boolean>;
24352435
};
2436-
}) => void | Promise<void>
2436+
}) => void
24372437
): {
24382438
method: 'POST';
24392439
action: string;

0 commit comments

Comments
 (0)