#协程
共 4 篇文章
Kotlin produceIn 的作用域取消后,receive 为什么有时抛 JobCancellationException
接收协程没被取消,receive 却收到 JobCancellationException 时,检查生产作用域和 channel 的结束原因。区分正常关闭、生产取消与接收者取消,用 receiveCatching 明确处理。
Coroutines 1.11.0 的 Flow 转 Flux 报 observation 不匹配,检查上下文恢复顺序
Flow 转 Flux 的 undispatched 挂起路径可能打乱 ThreadContextElement 恢复顺序,导致 observation 断言或 trace 串链;核对整组依赖和 dispatcher,按完整路径回归。
Fragment 收集 Flow 时 binding 空指针:把界面订阅绑定到 View 生命周期
Fragment 返回页面后 binding 空指针时,检查 Fragment 与 View 两套生命周期,用 viewLifecycleOwner 和 repeatOnLifecycle 管理订阅,保留 binding 清理。
LaunchedEffect 仍调用旧回调:区分 effect key 和 rememberUpdatedState
LaunchedEffect 等待结束后调用旧回调时,区分任务需要重启与回调需要更新,用 rememberUpdatedState 在执行时读取最新值,并核对 key 的业务含义。


