Workflow.then()
.then()
メソッドはワークフローステップ間の順次依存関係を作成し、ステップが特定の順序で実行されることを保証します。
使用方法
workflow.step(stepOne).then(stepTwo).then(stepThree);
パラメータ
step:
Step | string
前のステップが完了した後に実行されるべきステップインスタンスまたはステップID
戻り値
workflow:
Workflow
メソッドチェーン用のワークフローインスタンス
バリデーション
then
を使用する場合:
- 前のステップがワークフロー内に存在する必要があります
- ステップは循環依存関係を形成できません
- 各ステップは連続したチェーン内で一度だけ表示できます
エラー処理
try {
workflow
.step(stepA)
.then(stepB)
.then(stepA) // エラーが発生します - 循環依存関係
.commit();
} catch (error) {
if (error instanceof ValidationError) {
console.log(error.type); // 'circular_dependency'
console.log(error.details);
}
}