Skip to content

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()