You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/guide/reactivity-computed-watchers.md
+11-5Lines changed: 11 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ stop()
63
63
64
64
### Side Effect Invalidation
65
65
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:
67
67
68
68
- the effect is about to re-run
69
69
- 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
83
83
84
84
```js
85
85
constdata=ref(null)
86
-
watchEffect(asynconInvalidate=> {
87
-
onInvalidate(() => {...}) // we register cleanup function before Promise resolves
86
+
watchEffect(async(onInvalidate)=> {
87
+
onInvalidate(() => {/*...*/}) // we register cleanup function before Promise resolves
0 commit comments