Kotlin Coroutines: In Depth [FREE]

栏目: IT技术 · 发布时间: 4年前

Dive Into Coroutines

Take a tour around asynchronous programming mechanisms in Android, and learn what coroutines are, how they work, and why you should consider using them instead.

In this episode, start your first coroutine Job, and see what its lifecycle is.

Understand what the CoroutineContext is, and how it influences coroutines.

Explore some advanced Job relations and functionality, and how to communicate the lifecycle of coroutines to the rest of the project.

Implement Coroutines In Android

Learn the structure and the features of the project you'll be working on, and how to use the best practices of Kotlin Coroutines.

Launch the basic Kotlin Coroutine functions, to simplify background work in the project.

Learn how to bind your coroutines to the lifecycle of your app's components, such as Activities or Fragments.

Learn what context switching means, and how to bridge the gap between asynchronous and synchronous worlds. Dive into the concept of suspendability.

Separate business logic from context switching and threading by abstracting away implementation details. Decouple dependencies for context providing to support testing.

Debug & Test Coroutines

Handle errors that occur within coroutines with custom error handlers or manual exception catching. Or, instead of working with exceptions, wrap your data with a Result.

Apply needed changes to have a clear log of information, about which coroutines are running and in which threads.

Learn how to set up the testing environment, so you can easily run and test coroutines using JUnit 4 and Mockito, and verify the functionality of your code.

Coroutines With Libraries

Instead of awaiting a Response from Retrofit, use the suspend function approach to expect an entity model directly from the API.

Remove async calls and wrappers, and rely on the internal Room logic to fetch data without blocking.

Find out how to connect the Android Lifecycle and the CoroutineScope to handle cancellation automatically using ViewModels.


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

算法神探

算法神探

[美] 杰瑞米·库比卡 / 啊哈磊、李嘉浩 / 电子工业出版社 / 2017-2 / 65

《算法神探:一部谷歌首席工程师写的CS小说》围绕程序设计典型算法,精心编织了一个扣人心弦又趣味横生的侦探缉凶故事。小说主人公运用高超的搜索技巧和精深的算法知识,最终识破阴谋、缉拿元凶。其间,用二分搜索搜查走私船、用搜索树跟踪间谍、用深度优先搜索逃离监狱、用优先队列开锁及用最佳优先搜索追寻线索等跌宕起伏又富含算法精要的情节,让读者在愉悦的沉浸式体验中快速提升境界,加深对程序世界的理解。《算法神探:一......一起来看看 《算法神探》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

URL 编码/解码
URL 编码/解码

URL 编码/解码

html转js在线工具
html转js在线工具

html转js在线工具