Skip to content

Commit 122f44b

Browse files
committed
tweak docs
1 parent 2ab20e0 commit 122f44b

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

packages/svelte/src/ambient.d.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,18 @@ declare namespace $state {
6464
export function snapshot<T>(state: T): T;
6565

6666
/**
67-
* To take a check if two reactive from `$state()` are the same, use `$state.is`:
67+
* Compare two values, one or both of which is a reactive `$state(...)` proxy.
6868
*
6969
* Example:
7070
* ```ts
7171
* <script>
72-
* let state = $state({});
73-
* let object = {};
72+
* let foo = $state({});
73+
* let bar = {};
7474
*
75-
* state.object = object;
75+
* foo.bar = bar;
7676
*
77-
* console.log(state.object === object); // false because of the $state proxy
78-
*
79-
* console.log($state.is(state.object, object)); // true
77+
* console.log(foo.bar === bar); // false — `foo.bar` is a reactive proxy
78+
* console.log($state.is(foo.bar, bar)); // true
8079
* </script>
8180
* ```
8281
*

packages/svelte/types/index.d.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,19 +2625,18 @@ declare namespace $state {
26252625
export function snapshot<T>(state: T): T;
26262626

26272627
/**
2628-
* To take a check if two reactive from `$state()` are the same, use `$state.is`:
2628+
* Compare two values, one or both of which is a reactive `$state(...)` proxy.
26292629
*
26302630
* Example:
26312631
* ```ts
26322632
* <script>
2633-
* let state = $state({});
2634-
* let object = {};
2633+
* let foo = $state({});
2634+
* let bar = {};
26352635
*
2636-
* state.object = object;
2636+
* foo.bar = bar;
26372637
*
2638-
* console.log(state.object === object); // false because of the $state proxy
2639-
*
2640-
* console.log($state.is(state.object, object)); // true
2638+
* console.log(foo.bar === bar); // false — `foo.bar` is a reactive proxy
2639+
* console.log($state.is(foo.bar, bar)); // true
26412640
* </script>
26422641
* ```
26432642
*

sites/svelte-5-preview/src/routes/docs/content/01-api/02-runes.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,17 @@ This is handy when you want to pass some state to an external library or API tha
114114
115115
## `$state.is`
116116

117-
Sometimes you might need to deal with the equality of two values, where one of the objects might have been wrapped in a with a `$state` proxy,
118-
you can use `$state.is` to check if the two values are the same.
117+
Sometimes you might need to compare two values, one of which is a reactive `$state(...)` proxy. For this you can use `$state.is(a, b)`:
119118

120119
```svelte
121120
<script>
122-
let state = $state({});
123-
let object = {};
121+
let foo = $state({});
122+
let bar = {};
124123
125-
state.object = object;
124+
foo.bar = bar;
126125
127-
console.log(state.object === object); // false because of the $state proxy
128-
129-
console.log($state.is(state.object, object)); // true
126+
console.log(foo.bar === bar); // false — `foo.bar` is a reactive proxy
127+
console.log($state.is(foo.bar, bar)); // true
130128
</script>
131129
```
132130

0 commit comments

Comments
 (0)