MCPcopy
hub / github.com/vuejs/core / computed

Function computed

packages/reactivity/src/computed.ts:198–221  ·  view source on GitHub ↗
(
  getterOrOptions: ComputedGetter<T> | WritableComputedOptions<T>,
  debugOptions?: DebuggerOptions,
  isSSR = false,
)

Source from the content-addressed store, hash-verified

196): WritableComputedRef<T, S>
197/*@__NO_SIDE_EFFECTS__*/
198export function computed<T>(
199 getterOrOptions: ComputedGetter<T> | WritableComputedOptions<T>,
200 debugOptions?: DebuggerOptions,
201 isSSR = false,
202) {
203 let getter: ComputedGetter<T>
204 let setter: ComputedSetter<T> | undefined
205
206 if (isFunction(getterOrOptions)) {
207 getter = getterOrOptions
208 } else {
209 getter = getterOrOptions.get
210 setter = getterOrOptions.set
211 }
212
213 const cRef = new ComputedRefImpl(getter, setter, isSSR)
214
215 if (__DEV__ && debugOptions && !isSSR) {
216 cRef.onTrack = debugOptions.onTrack
217 cRef.onTrigger = debugOptions.onTrigger
218 }
219
220 return cRef as any
221}

Callers 15

watch.spec.tsFile · 0.90
useClampFunction · 0.90
computed.spec.tsFile · 0.90
setupFunction · 0.90
reactive.spec.tsFile · 0.90
readonly.spec.tsFile · 0.90
computed.bench.tsFile · 0.50
gc.spec.tsFile · 0.50

Calls 1

isFunctionFunction · 0.90

Tested by 3

useClampFunction · 0.72
setupFunction · 0.72
testRenderFunction · 0.40