Skip to content

Commit 7de6190

Browse files
Merge branch 'master' of github.com:vuejs/docs-next
2 parents c233b25 + d3e52e9 commit 7de6190

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/api/refs-api.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,26 @@ isReactive(foo.value) // false
210210
```
211211

212212
**See also**: [Creating Standalone Reactive Values as `refs`](../guide/reactivity-fundamentals.html#creating-standalone-reactive-values-as-refs)
213+
214+
## `triggerRef`
215+
216+
Execute any effects tied to a [`shallowRef`](#shallowref) manually.
217+
218+
```js
219+
const shallow = shallowRef({
220+
greet: 'Hello, world'
221+
})
222+
223+
// Logs "Hello, world" once for the first run-through
224+
watchEffect(() => {
225+
console.log(shallow.value.greet)
226+
})
227+
228+
// This won't trigger the effect because the ref is shallow
229+
shallow.value.greet = 'Hello, universe'
230+
231+
// Logs "Hello, universe"
232+
triggerRef(shallow)
233+
```
234+
235+
**See also:** [Computed and Watch - watchEffect](./computed-watch-api.html#watcheffect)

0 commit comments

Comments
 (0)