MCPcopy
hub / github.com/vuejs/composition-api / activateCurrentInstance

Function activateCurrentInstance

src/utils/instance.ts:190–211  ·  view source on GitHub ↗
(
  instance: ComponentInternalInstance,
  fn: (instance: ComponentInternalInstance) => any,
  onError?: (err: Error) => void
)

Source from the content-addressed store, hash-verified

188}
189
190export function activateCurrentInstance(
191 instance: ComponentInternalInstance,
192 fn: (instance: ComponentInternalInstance) => any,
193 onError?: (err: Error) => void
194) {
195 let preVm = getCurrentInstance()
196 setCurrentInstance(instance)
197 try {
198 return fn(instance)
199 } catch (
200 // FIXME: remove any
201 err: any
202 ) {
203 if (onError) {
204 onError(err)
205 } else {
206 throw err
207 }
208 } finally {
209 setCurrentInstance(preVm)
210 }
211}

Callers 2

functionApiInitFunction · 0.90
initSetupFunction · 0.90

Calls 3

getCurrentInstanceFunction · 0.90
setCurrentInstanceFunction · 0.90
onErrorFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…