Skip to content

Commit 23c4360

Browse files
authored
Editorial Fixes (#735)
1 parent 3ad6eaf commit 23c4360

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/guide/reactivity-computed-watchers.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ stop()
6363

6464
### Side Effect Invalidation
6565

66-
Sometimes the watched effect function will perform asynchronous side effects that need to be cleaned up when it is invalidated (i.e state changed before the effects can be completed). The effect function receives an `onInvalidate` function that can be used to register an invalidation callback. This invalidation callback is called when:
66+
Sometimes the watched effect function will perform asynchronous side effects that need to be cleaned up when it is invalidated (i.e. state changed before the effects can be completed). The effect function receives an `onInvalidate` function that can be used to register an invalidation callback. This invalidation callback is called when:
6767

6868
- the effect is about to re-run
6969
- the watcher is stopped (i.e. when the component is unmounted if `watchEffect` is used inside `setup()` or lifecycle hooks)
@@ -83,8 +83,8 @@ We are registering the invalidation callback via a passed-in function instead of
8383

8484
```js
8585
const data = ref(null)
86-
watchEffect(async onInvalidate => {
87-
onInvalidate(() => {...}) // we register cleanup function before Promise resolves
86+
watchEffect(async (onInvalidate) => {
87+
onInvalidate(() => { /* ... */ }) // we register cleanup function before Promise resolves
8888
data.value = await fetchData(props.id)
8989
})
9090
```
@@ -200,9 +200,15 @@ watch(count, (count, prevCount) => {
200200
A watcher can also watch multiple sources at the same time using an array:
201201

202202
```js
203-
watch([fooRef, barRef], ([foo, bar], [prevFoo, prevBar]) => {
204-
/* ... */
203+
const firstName = ref('');
204+
const lastName= ref('');
205+
206+
watch([firstName, lastName], (newValues, prevValues) => {
207+
console.log(newValues, prevValues);
205208
})
209+
210+
firstName.value = "John"; // logs: ["John",""] ["", ""]
211+
lastName.value = "Smith"; // logs: ["John", "Smith"] ["John", ""]
206212
```
207213

208214
### Shared Behavior with `watchEffect`

0 commit comments

Comments
 (0)