feat(reactivity): add triggerRef API

Also make shallowRef assignment behavior consistent with normal ref
This commit is contained in:
Evan You
2020-04-22 18:00:10 -04:00
parent 3e60288a6d
commit 2acf3e84b9
4 changed files with 14 additions and 3 deletions

View File

@@ -9,7 +9,7 @@ import {
isReactive
} from '../src/index'
import { computed } from '@vue/runtime-dom'
import { shallowRef, unref, customRef } from '../src/ref'
import { shallowRef, unref, customRef, triggerRef } from '../src/ref'
describe('reactivity/ref', () => {
it('should hold a value', () => {
@@ -194,7 +194,7 @@ describe('reactivity/ref', () => {
expect(dummy).toBe(1) // should not trigger yet
// force trigger
sref.value = sref.value
triggerRef(sref)
expect(dummy).toBe(2)
})