Finish a fact
Sometimes a fact must be changed before anyone reads it: an author's id hashed for privacy, a tenant
looked up with a service the announcer should not hold. An operation taking Pipe<T> does it — it
receives the fact, and what it returns is what every listener reads.
To leave a field out, you need no link: a fact is already a cut of an entity, so simply do not declare the field. A link is for what must be transformed.
Write the link
// fronds/privacy/handlers/HashHandler.ts
export default class HashHandler {
constructor(private salt: Salt) {}
async set(fact: Pipe<PostPublished>): Promise<PostPublished> {
return { ...fact, author: this.salt.hash(fact.author) };
}
}
It receives the whole fact and must answer one — a link that answers nothing is refused.
Order them, in the frond that owns the fact
Several links run in an order, each reading what the previous one answered. The order belongs to the frond that owns the fact:
// fronds/blog/frond.config.ts — blog owns postPublished
export default { pipes: { postPublished: ['TenantHandler', 'HashHandler'] } };
The boot refuses:
- two links with no order, naming both;
- a link the order does not list;
- a frond ordering a fact it does not own.
What it costs
A link is a hard dependency, where a listener is not: a listener that throws is logged and the
announcement goes on; a link that throws stops it. A link is called, so it has an address — in this
process or in fronds: — and cannot sit behind a carrier.
pipe-split runs it in one process, then split.