Skip to main content
InterviewHubPRO
Section Overview
Q25

Question 25 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

50%
Vue.js & Composition API (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

Deep Dive into Vue 3 Reactivity Internals: `track()`, `trigger()`, and `TargetMap`.

senior LevelCode ExampleSystem DesignVue & Nuxt

In Simple Words: Under the hood, Vue's reactivity engine uses a global WeakMap:

javascript
TargetMap: WeakMap<TargetObject, Map<PropertyKey, Set<ReactiveEffect>>>
  1. track(target, key) (During Property Read - Getter):
    • When active code (e.g. a component render function or computed) reads a property, track adds the currently running ReactiveEffect into the property's Set of subscribers.
  2. trigger(target, key) (During Property Write - Setter):
    • When a property is modified, trigger looks up all effects registered in the property's Set and executes them.