Meteor Deep Dive

Reactive Programming With Tracker

How does the magic happen?

Warning

This is not the entry level

What is Tracker?

Reactive Programming

a = b + c

How does Tracker do RP?

How does Tracker work its magic?

Do you know an OOP design pattern used to look for changes of an object and notify other objects which subscribe to those changes?

Observer pattern

Publish/subscribe pattern

Let's dive into the code

The flow of Tracker



  1. Tracker.autorun
  2. new Tracker.Computation (call this C)
  3. C sets itself as the global currentComputation and runs for the first time
  4. Subject.depend() is call and add C to its dependents list
  5. Subject.change() will lookup and rerun all dependent computations

Note: that is not the complete Tracker

Computation inside computation

Clear cache

Prevent infinite loop

Thank you