Skip to content

Commit 666b482

Browse files
sync kit docs
1 parent f5a7cc5 commit 666b482

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
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: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,13 +1600,17 @@ Information about the target of a specific navigation.
16001600
<div class="ts-block">
16011601

16021602
```dts
1603-
interface NavigationTarget {/*…*/}
1603+
interface NavigationTarget<
1604+
Params extends
1605+
AppLayoutParams<'/'> = AppLayoutParams<'/'>,
1606+
RouteId extends AppRouteId | null = AppRouteId | null
1607+
> {/*…*/}
16041608
```
16051609

16061610
<div class="ts-block-property">
16071611

16081612
```dts
1609-
params: Record<string, string> | null;
1613+
params: Params | null;
16101614
```
16111615

16121616
<div class="ts-block-property-details">
@@ -1630,7 +1634,7 @@ Info about the target route
16301634
<div class="ts-block-property-children"><div class="ts-block-property">
16311635

16321636
```dts
1633-
id: string | null;
1637+
id: RouteId | null;
16341638
```
16351639

16361640
<div class="ts-block-property-details">
@@ -1928,14 +1932,16 @@ The return value of a remote `command` function. See [Remote functions](/docs/ki
19281932
<div class="ts-block">
19291933

19301934
```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>>;
1935+
type RemoteCommand<Input, Output> = {
1936+
(arg: Input): Promise<Awaited<Output>> & {
1937+
updates(
1938+
...queries: Array<
1939+
RemoteQuery<any> | RemoteQueryOverride
1940+
>
1941+
): Promise<Awaited<Output>>;
1942+
};
1943+
/** The number of pending command executions */
1944+
get pending(): number;
19391945
};
19401946
```
19411947

@@ -1991,6 +1997,8 @@ type RemoteForm<Result> = {
19911997
): Omit<RemoteForm<Result>, 'for'>;
19921998
/** The result of the form submission */
19931999
get result(): Result | undefined;
2000+
/** The number of pending submissions */
2001+
get pending(): number;
19942002
/** Spread this onto a `<button>` or `<input type="submit">` */
19952003
buttonProps: {
19962004
type: 'submit';
@@ -2016,6 +2024,8 @@ type RemoteForm<Result> = {
20162024
formaction: string;
20172025
onclick: (event: Event) => void;
20182026
};
2027+
/** The number of pending submissions */
2028+
get pending(): number;
20192029
};
20202030
};
20212031
```
@@ -2050,7 +2060,7 @@ type RemoteQuery<T> = RemoteResource<T> & {
20502060
*/
20512061
refresh(): Promise<void>;
20522062
/**
2053-
* Temporarily override the value of a query. This is used with the `updates` method of a [command](https://svelte.dev/docs/kit/remote-functions#command-Single-flight-mutations) or [enhanced form submission](https://svelte.dev/docs/kit/remote-functions#form-enhance) to provide optimistic updates.
2063+
* Temporarily override the value of a query. This is used with the `updates` method of a [command](https://svelte.dev/docs/kit/remote-functions#command-Updating-queries) or [enhanced form submission](https://svelte.dev/docs/kit/remote-functions#form-enhance) to provide optimistic updates.
20542064
*
20552065
* ```svelte
20562066
* <script>

0 commit comments

Comments
 (0)