Skip to content

Commit c998313

Browse files
sync kit docs
1 parent f5a7cc5 commit c998313

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,11 @@ Now simply call `addLike`, from (for example) an event handler:
504504
505505
> [!NOTE] Commands cannot be called during render.
506506
507-
### Single-flight mutations
507+
### Updating queries
508+
509+
To update `getLikes(item.id)`, or any other query, we need to tell SvelteKit _which_ queries need to be refreshed (unlike `form`, which by default invalidates everything, to approximate the behaviour of a native form submission).
508510
509-
As with forms, any queries on the page (such as `getLikes(item.id)` in the example above) will automatically be refreshed following a successful command. But we can make things more efficient by telling SvelteKit which queries will be affected by the command, either inside the command itself...
511+
We either do that inside the command itself...
510512
511513
```js
512514
/// file: likes.remote.js

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,14 +1928,16 @@ The return value of a remote `command` function. See [Remote functions](/docs/ki
19281928
<div class="ts-block">
19291929

19301930
```dts
1931-
type RemoteCommand<Input, Output> = (arg: Input) => Promise<
1932-
Awaited<Output>
1933-
> & {
1934-
updates(
1935-
...queries: Array<
1936-
RemoteQuery<any> | RemoteQueryOverride
1937-
>
1938-
): Promise<Awaited<Output>>;
1931+
type RemoteCommand<Input, Output> = {
1932+
(arg: Input): Promise<Awaited<Output>> & {
1933+
updates(
1934+
...queries: Array<
1935+
RemoteQuery<any> | RemoteQueryOverride
1936+
>
1937+
): Promise<Awaited<Output>>;
1938+
};
1939+
/** The number of pending command executions */
1940+
get pending(): number;
19391941
};
19401942
```
19411943

@@ -1991,6 +1993,8 @@ type RemoteForm<Result> = {
19911993
): Omit<RemoteForm<Result>, 'for'>;
19921994
/** The result of the form submission */
19931995
get result(): Result | undefined;
1996+
/** The number of pending submissions */
1997+
get pending(): number;
19941998
/** Spread this onto a `<button>` or `<input type="submit">` */
19951999
buttonProps: {
19962000
type: 'submit';
@@ -2016,6 +2020,8 @@ type RemoteForm<Result> = {
20162020
formaction: string;
20172021
onclick: (event: Event) => void;
20182022
};
2023+
/** The number of pending submissions */
2024+
get pending(): number;
20192025
};
20202026
};
20212027
```

0 commit comments

Comments
 (0)