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/api/computed-watch-api.md
+24-3Lines changed: 24 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -34,10 +34,31 @@ console.log(count.value) // 0
34
34
35
35
```ts
36
36
// read-only
37
-
function computed<T>(getter: () =>T):Readonly<Ref<Readonly<T>>>
37
+
function computed<T>(
38
+
getter: () =>T,
39
+
debuggerOptions?:DebuggerOptions
40
+
):Readonly<Ref<Readonly<T>>>
38
41
39
42
// writable
40
-
function computed<T>(options: { get: () =>T; set: (value:T) =>void }):Ref<T>
43
+
function computed<T>(
44
+
options: {
45
+
get: () =>T
46
+
set: (value:T) =>void
47
+
},
48
+
debuggerOptions?:DebuggerOptions
49
+
):Ref<T>
50
+
51
+
interfaceDebuggerOptions {
52
+
onTrack?: (event:DebuggerEvent) =>void
53
+
onTrigger?: (event:DebuggerEvent) =>void
54
+
}
55
+
56
+
interfaceDebuggerEvent {
57
+
effect:ReactiveEffect
58
+
target:any
59
+
type:OperationTypes
60
+
key:string|symbol|undefined
61
+
}
41
62
```
42
63
43
64
## `watchEffect`
@@ -94,7 +115,7 @@ Alias of `watchEffect` with `flush: 'sync'` option.
94
115
95
116
## `watch`
96
117
97
-
The`watch`APIistheexactequivalentoftheOptionsAPI [this.$watch](./instance-methods.html#watch) (andthecorresponding [watch](./options-data.html#watch) option). `watch`requireswatchingaspecificdatasourceandappliessideeffectsinaseparatecallbackfunction. It also is lazy by default - i.e. the callback is only called when the watched source has changed.
118
+
The `watch` API is the exact equivalent of the Options API [this.\$watch](./instance-methods.html#watch) (and the corresponding [watch](./options-data.html#watch) option). `watch` requires watching a specific data source and applies side effects in a separate callback function. It also is lazy by default - i.e. the callback is only called when the watched source has changed.
98
119
99
120
- Compared to [watchEffect](#watcheffect), `watch` allows us to:
0 commit comments