loop

inline suspend fun <S : Stage<S>> StageLoop<S>.loop(crossinline condition: (next: S?) -> Boolean = { next -> next != null }, crossinline exceptionHandle: (Throwable) -> Unit = { e -> throw e })

通过提供的 StageLoop 进行循环。

Parameters

condition

每次循环时的条件判断。默认为 next != null。 可以配合其他条件实现声明周期控制,例如 Job

val job: Job = ...
stageLoop.loop(condition = { next -> job.isActive && next != null })
exceptionHandle

每个阶段循环到并执行时的异常处理器