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
**Ver também**: [Guia do `watchEffect`](../guide/reactivity-computed-watchers.html#watcheffect)
107
107
108
108
## `watchPostEffect` <Badge text="3.2+" />
109
109
110
-
Alias of`watchEffect`with `flush:'post'` option.
110
+
Apelido de`watchEffect`com a opção `flush:'post'`.
111
111
112
112
## `watchSyncEffect` <Badge text="3.2+" />
113
113
114
-
Alias of`watchEffect`with `flush:'sync'` option.
114
+
Apelido de`watchEffect`com a opção `flush:'sync'`.
115
115
116
116
## `watch`
117
117
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.
118
+
A API do `watch`é o equivalente exato da API de Opções [this.\$watch](./instance-methods.html#watch) (e a opção [watch](./options-data.html#watch) correspondente). `watch`requer a observação de uma fonte de dados específica e aplica efeitos colaterais em uma função _callback_ separada. Também é preguiçoso por padrão - ou seja, o _callback_ só é chamado quando a fonte monitorada é alterada.
119
119
120
-
- Compared to [watchEffect](#watcheffect), `watch`allows us to:
120
+
- Comparado com [watchEffect](#watcheffect), `watch`nos permite:
121
121
122
-
- Perform the side effect lazily;
123
-
- Be more specific about what state should trigger the watcher to re-run;
124
-
- Access both the previous and current value of the watched state.
122
+
- Executar o efeito colateral preguiçosamente;
123
+
- Ser mais específico sobre qual estado deve fazer com que o observador seja executado novamente;
124
+
- Acessar o valor anterior e o atual do estado observado.
125
125
126
-
### Watching a Single Source
126
+
### Observando uma Única Fonte
127
127
128
-
A watcher data source can either be a getter function that returns a value, or directly a [ref](./refs-api.html#ref):
128
+
A fonte de dados do observador pode ser uma função _getter_ que retorna um valor ou diretamente um [ref](./refs-api.html#ref):
129
129
130
130
```js
131
-
//watching a getter
131
+
//observando um getter
132
132
const state =reactive({ count: 0 })
133
133
watch(
134
134
() =>state.count,
@@ -137,31 +137,31 @@ watch(
137
137
}
138
138
)
139
139
140
-
//directly watching a ref
140
+
//observando diretamente uma ref
141
141
const count =ref(0)
142
142
watch(count, (count, prevCount) => {
143
143
/* ... */
144
144
})
145
145
```
146
146
147
-
### Watching Multiple Sources
147
+
### Observando Várias Fontes
148
148
149
-
A watcher can also watch multiple sources at the same time using an array:
149
+
Um observador também pode observar várias fontes ao mesmo tempo usando um array:
`watch`shares behavior with[`watchEffect`](#watcheffect)in terms of [manual stoppage](../guide/reactivity-computed-watchers.html#stopping-the-watcher), [side effect invalidation](../guide/reactivity-computed-watchers.html#side-effect-invalidation) (with`onInvalidate`passed to the callback as the 3rd argument instead), [flush timing](../guide/reactivity-computed-watchers.html#effect-flush-timing) and [debugging](../guide/reactivity-computed-watchers.html#watcher-debugging).
159
+
`watch`compartilha comportamento com[`watchEffect`](#watcheffect)em termos de [interrupção manual](../guide/reactivity-computed-watchers.html#parando-o-observador), [invalidação de efeito colateral](../guide/reactivity-computed-watchers.html#invalidacao-de-efeito-colateral) (com`onInvalidate`passado para o _callback_ como o terceiro argumento), [momento de limpeza](../guide/reactivity-computed-watchers.html#momento-de-limpeza-do-efeito) e [depuração](../guide/reactivity-computed-watchers.html#depuracao-do-observador).
0 commit comments