13

掌握Kotlin Coroutine之 演示项目

 3 years ago
source link: http://blog.chengyunfeng.com/?p=1095
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

掌握Kotlin Coroutine之 演示项目

作者: rain 分类: 移动 发布时间: 2019-03-28 09:26 6 0条评论

谷歌有一个 Todo 项目用来演示不同的安卓开发架构,在 todo-mvp-kotlin 项目基础上使用 1.1.1 版本的 Coroutine 和 2.1.0-alpha05 版本的 room 演示了如何在安卓应用中使用 Coroutine。 2.1.0-alpha05 版本的room 支持 suspend 关键字,通过该关键字定义的函数可以在 Coroutine 中使用。

在该修改过的项目中主要演示了如何使用前面介绍到的一些概念,比如 Activity 中通过 MainScope() 实现 CoroutineScope、通过 launch 函数来执行后台保存数据到数据库的操作。

该项目还演示了一些 Kotlin 语言的特性,对 Kotlin 不太熟悉的可以详细看看里面的一些 Kotlin 用法,比如 util 包中的一些扩展函数的使用。

使用Coroutine 的项目地址:https://github.com/goodev/todo-room-kotlin-coroutine
官方的 android-architecture 项目地址:https://github.com/googlesamples/android-architecture


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK