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

Function observe

src/reactivity/reactive.ts:116–136  ·  view source on GitHub ↗
(obj: T)

Source from the content-addressed store, hash-verified

114}
115
116export function observe<T>(obj: T): T {
117 const Vue = getRegisteredVueOrDefault()
118 let observed: T
119 if (Vue.observable) {
120 observed = Vue.observable(obj)
121 } else {
122 const vm = defineComponentInstance(Vue, {
123 data: {
124 $$state: obj,
125 },
126 })
127 observed = vm._data.$$state
128 }
129
130 // in SSR, there is no __ob__. Mock for reactivity check
131 if (!hasOwn(observed, '__ob__')) {
132 mockReactivityDeep(observed)
133 }
134
135 return observed
136}
137
138/**
139 * Mock __ob__ for object recursively

Callers 4

shallowReadonlyFunction · 0.90
createObserverFunction · 0.85
shallowReactiveFunction · 0.85
reactiveFunction · 0.85

Calls 5

defineComponentInstanceFunction · 0.90
hasOwnFunction · 0.90
mockReactivityDeepFunction · 0.85
observableMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…