@@ -17,9 +17,9 @@ const scope = effectScope()
17
17
scope .run (() => {
18
18
const doubled = computed (() => counter .value * 2 )
19
19
20
- watch (doubled , () => console .log (double .value ))
20
+ watch (doubled , () => console .log (doubled .value ))
21
21
22
- watchEffect (() => console .log (' Count: ' , double .value ))
22
+ watchEffect (() => console .log (' Count: ' , doubled .value ))
23
23
})
24
24
25
25
// to dispose all effects in the scope
@@ -47,7 +47,7 @@ const stopWatch1 = watchEffect(() => {
47
47
disposables .push (stopWatch1 )
48
48
49
49
const stopWatch2 = watch (doubled , () => {
50
- console .log (double .value )
50
+ console .log (doubled .value )
51
51
})
52
52
53
53
disposables .push (stopWatch2 )
@@ -96,9 +96,9 @@ A scope can run a function and will capture all effects created during the funct
96
96
scope .run (() => {
97
97
const doubled = computed (() => counter .value * 2 )
98
98
99
- watch (doubled , () => console .log (double .value ))
99
+ watch (doubled , () => console .log (doubled .value ))
100
100
101
- watchEffect (() => console .log (' Count: ' , double .value ))
101
+ watchEffect (() => console .log (' Count: ' , doubled .value ))
102
102
})
103
103
104
104
// the same scope can run multiple times
@@ -133,10 +133,10 @@ scope.run(() => {
133
133
134
134
// not need to get the stop handler, it will be collected by the outer scope
135
135
effectScope ().run (() => {
136
- watch (doubled , () => console .log (double .value ))
136
+ watch (doubled , () => console .log (doubled .value ))
137
137
})
138
138
139
- watchEffect (() => console .log (' Count: ' , double .value ))
139
+ watchEffect (() => console .log (' Count: ' , doubled .value ))
140
140
})
141
141
142
142
// dispose all effects, including those in the nested scopes
@@ -150,7 +150,7 @@ scope.stop()
150
150
This also makes usages like [ "lazy initialization"] ( https://github.com/vuejs/vue-next/issues/1532 ) possible.
151
151
152
152
``` ts
153
- let childScope
153
+ let nestedScope
154
154
155
155
const parentScope = effectScope ()
156
156
@@ -159,15 +159,15 @@ parentScope.run(() => {
159
159
160
160
// with the detected flag,
161
161
// the scope will not be collected and disposed by the outer scope
162
- childScope = effectScope (true /* detached */ )
163
- childScope .run (() => {
164
- watch (doubled , () => console .log (double .value ))
162
+ nestedScope = effectScope (true /* detached */ )
163
+ nestedScope .run (() => {
164
+ watch (doubled , () => console .log (doubled .value ))
165
165
})
166
166
167
- watchEffect (() => console .log (' Count: ' , double .value ))
167
+ watchEffect (() => console .log (' Count: ' , doubled .value ))
168
168
})
169
169
170
- // disposes all effects, but not `childScope `
170
+ // disposes all effects, but not `nestedScope `
171
171
parentScope .stop ()
172
172
173
173
// stop the nested scope only when appropriate
0 commit comments