vue-lynx / triggerRef

Function: triggerRef()

function triggerRef(ref): void

Force trigger effects that depends on a shallow ref. This is typically used after making deep mutations to the inner value of a shallow ref.

Parameters

ParameterTypeDescription
refRef<any, any>The ref whose tied effects shall be executed.

Returns

void

Example

const shallow = shallowRef({
  greet: 'Hello, world'
})

// Logs "Hello, world" once for the first run-through
watchEffect(() => {
  console.log(shallow.value.greet)
})

// This won't trigger the effect because the ref is shallow
shallow.value.greet = 'Hello, universe'

// Logs "Hello, universe"
triggerRef(shallow)

See

https://vuejs.org/api/reactivity-advanced.html#triggerref

Defined in

node_modules/.pnpm/@vue+reactivity@3.5.30/node_modules/@vue/reactivity/dist/reactivity.d.ts:490