@@ -142,18 +142,24 @@ convention.
142142names after the host language's control flow:
143143
144144``` ts
145- const gated = dag . task ( " has_rows " , async ( { rows }: { rows: number }) => rows > 0 )( {
146- rows: extracted ,
147- });
145+ async function hasRows( { rows }: { rows: number }): Promise < boolean > {
146+ return rows > 0 ;
147+ }
148148
149- dag .if (gated ).then (loadIfReady ).else (loadFallback );
149+ const gate = dag .if (hasRows )({ rows: validated });
150+ gate .then (loadIfReady ).else (loadFallback );
150151```
151152
152- ** The condition is a task reference, not a task id and a function.** ` dag.if ` takes a ` TaskRef ` the
153- Dag already handed back, whose handler's return type the compiler checks is ` boolean ` . So nothing
154- depends on the task's id or on its function name, and a condition is declared, named and typed the
155- same way every other task is. The same reasoning that makes a * case* a reference in that ADR's
156- decision 2 applies to the condition itself.
153+ ** The condition is a handler, declared the way a task is.** That ADR writes
154+ ` dag.If(hasRows, airflow.Inputs(validated)) ` in Go, where ` dag.Task(fn, airflow.Inputs(x)) ` declares
155+ and wires a task in one call. TypeScript splits that call into ` dag.task(fn)({ x }) ` , so ` dag.if `
156+ splits the same way: ` dag.if(hasRows) ` declares the deciding task, taking its id from the function's
157+ name unless ` taskId ` sets it, and the returned factory takes its inputs. The compiler checks that the
158+ handler returns a ` boolean ` .
159+
160+ ** A condition is a node.** What the factory returns carries ` before ` and ` after ` , and stands at the
161+ other end of an edge as the deciding task, so ` notified.after(gate) ` reads as Go's ` .After(gate) ` . It
162+ is also a valid branch of another condition.
157163
158164** A ` then ` chain is a thenable, and is guarded rather than avoided.** An object with a callable
159165` then ` is a * thenable* : were the object ` dag.if ` returns to reach an ` await ` , the runtime would hand
0 commit comments