13. 速查表
| 需求 | 写法 |
|---|---|
| 启动(无返回值) | scope.launch { } |
| 启动(有返回值) | async { }.await() |
| 切线程 | withContext(Dispatchers.IO) |
| 挂起等待 | delay(1000) |
| 取消 | job.cancel() |
| 超时 | withTimeout(2000) { } |
| 多值流 | flow { emit(x) } |
| UI 状态 | MutableStateFlow + asStateFlow |
| 绑生命周期 | viewModelScope / lifecycleScope |
| 互不连坐 | supervisorScope { } |