Sharing Tags
A Tag holds a value Tasks read.
The first instinct is one Tag per Task — it feels safe. Repeat that across the codebase, and you end up with many Tags meaning almost the same thing.
A simpler rule: one Tag for the same meaning; a new Tag for a different one.
A Tag with only one reader is fine; the rule is about meaning, not Task count.
import { auth } from "./auth"
const userId = tag<string>("userId")
const dashboard = createTask({ name: "dashboard", run: { context: userId.value, fn: (id) => console.log(`dashboard for ${id}`), },})
const profile = createTask({ name: "profile", run: { context: userId.value, fn: (id) => console.log(`profile for ${id}`), },})
compose() .step(auth) .step(createWire({ from: auth.result.id, to: userId })) .step([dashboard, profile]) .run()import { auth } from "./auth"
const dashboardUserId = tag<string>("dashboardUserId")
const dashboard = createTask({ name: "dashboard", run: { context: dashboardUserId.value, fn: (id) => console.log(`dashboard for ${id}`), },})
// ❌ anti-pattern: same meaning, new Tag with no semantic reasonconst profileUserId = tag<string>("profileUserId")
const profile = createTask({ name: "profile", run: { context: profileUserId.value, fn: (id) => console.log(`profile for ${id}`), },})
compose() .step(auth) .step([ createWire({ from: auth.result.id, to: dashboardUserId }), createWire({ from: auth.result.id, to: profileUserId }), ]) .step([dashboard, profile]) .run()