Kotlin
文章平均质量分 64
ClevelandAlto
这个作者很懒,什么都没留下…
展开
-
Kotlin Coroutine(一)
Kotlin协程的理解原创 2017-12-16 20:58:32 · 507 阅读 · 0 评论 -
Kotlin Coroutine (二)
上一篇说完了协程的整个生命周期,总结一下:用Coroutine Builder函数(launch,startCoroutine等)创建协程 库内部使用createCoroutineUnchecked来创建协程,需要借助编译器的帮助协程中的指令开始顺序执行调用另一个suspend函数,直到调用到suspendCoroutine系列的函数 如果suspendCoroutine在同步返回前原创 2018-01-05 14:42:56 · 301 阅读 · 0 评论 -
在suspendCoroutine中用throw代替resumeWithException
举个例子suspend fun foo() { try { suspendCoroutine { cont -> throw Error() } } catch (ex: Throwable) { println("catch") } println("done")}这样throw其实和cont.resumeWithE...原创 2018-04-04 11:21:39 · 2241 阅读 · 0 评论