Dear Matt Debergalis (@debergalis), David Greenspan (@dgreensp), Geoff Schmidt (@gschmidt), and Nick Martin,
What were the inspirations for Tracker (previously known as Deps), the dependency-tracking auto-running reactivity system? What were the prior arts that led to it?
Today, the web world is getting enveloped in “Signals and Effects”, the new term for the same sort of reactivity popularized by Solid.js.
With Meteor the pattern looks like this:
import { Tracker } from 'meteor/tracker'
import { ReactiveVar } from 'meteor/reactive-var'
const a = new ReactiveVar(0)
const b = new ReactiveVar(0)
// Update a every second
setInterval(() => a.set(a.get() + 1), 1000)
// Update b every 0.7 seconds
setInterval(() => b.set(b.get() * 1.1), 700)
Tracker.autorun(() => {
// This re-runs any time a or b change.
console.log(a.get(), b.get())
})
In Solid.js, it looks similar:
import {createSignal, createEffect} from 'solid-js'
const [a, setA] = createSignal(0)
const [b, setB] = createSignal(0)
// Update a every second
setInterval(() => setA(a() + 1), 1000)
// Update b every 0.7 seconds
setInterval(() => setB(b() * 1.1), 700)
createEffect(() => {
// This re-runs any time a or b change.
console.log(a(), b())
})
And nowadays other libraries like Preact Signals, Vue Reactivity which was notably inspired by Meteor, Svelte Runes, MobX, Surplus.js which was a direct inspiration for Solid.js, and others, implement something similar where “effects” (or “computations”) automatically re-run when values used inside of them change. They all have varying but similar APIs, with varying strengths and weaknesses.
What pre-existing patterns, libraries, or frameworks, existed before Meteor that inspired this pattern in Meteor Tracker?
– Joe Pea