| 260 | * @param key - Identifier of the reactive property to track. |
| 261 | */ |
| 262 | export 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 |