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

Function track

packages/reactivity/src/dep.ts:262–284  ·  view source on GitHub ↗
(target: object, type: TrackOpTypes, key: unknown)

Source from the content-addressed store, hash-verified

260 * @param key - Identifier of the reactive property to track.
261 */
262export function track(target: object, type: TrackOpTypes, key: unknown): void {
263 if (shouldTrack && activeSub) {
264 let depsMap = targetMap.get(target)
265 if (!depsMap) {
266 targetMap.set(target, (depsMap = new Map()))
267 }
268 let dep = depsMap.get(key)
269 if (!dep) {
270 depsMap.set(key, (dep = new Dep()))
271 dep.map = depsMap
272 dep.key = key
273 }
274 if (__DEV__) {
275 dep.track({
276 target,
277 type,
278 key,
279 })
280 } else {
281 dep.track()
282 }
283 }
284}
285
286/**
287 * Finds all deps associated with the target (or a specific property) and

Callers 15

createIterableMethodFunction · 0.90
getFunction · 0.90
sizeFunction · 0.90
hasFunction · 0.90
forEachFunction · 0.90
reactiveReadArrayFunction · 0.90
shallowReadArrayFunction · 0.90
searchProxyFunction · 0.90
hasOwnPropertyFunction · 0.90
getMethod · 0.90
hasMethod · 0.90
ownKeysMethod · 0.90

Calls 3

trackMethod · 0.80
getMethod · 0.45
setMethod · 0.45

Tested by 1

getFunction · 0.68