jason810496 commented on code in PR #74069:
URL: https://github.com/apache/airflow/pull/74069#discussion_r4164086613
##########
airflow-core/docs/authoring-and-scheduling/language-sdks/typescript.rst:
##########
@@ -359,6 +359,34 @@ there. Set it once on the Dag and each task inherits it:
``queue`` on a task wins over the Dag's. See
:ref:`typescript-sdk/coordinator-config` for the
``queue_to_coordinator`` entry that sends that queue to the coordinator.
+Conditional branching
+~~~~~~~~~~~~~~~~~~~~~
+
+``dag.if`` takes a handler that returns a boolean, and names the task each
outcome runs:
+
+.. code-block:: typescript
+
+ async function hasRows({ rows }: { rows: number }): Promise<boolean> {
+ return rows > 0;
+ }
+
+ const gate = dag.if(hasRows)({ rows: extracted });
Review Comment:
Would it be possible to make the interface like:
```ts
dag.if(fn, opts...).then()
```
So that the following shape can work
```ts
dag.If(hasRows, { rows: extracted })).then(...)
// or explicitly set the task_id
dag.If(hasRows, "has_rows", { rows: extracted })).then(...)
```
Not sure would this be more straightforward?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]