|
所在平台: Udemy |
课程主页: https://www.udemy.com/course/coroutines-on-android/
课程评论:没有评论
课程名称:Kotlin协程与Flow在Android开发中的应用 课程概述:谷歌推荐Kotlin协程和Flow作为Android中异步编程的首选解决方案。每个Android开发者迟早都会接触到这些主题。本课程将深入讲解Kotlin协程和Flow,并展示如何在Android应用中实现最常见的用例。本课程分为两个主要部分:协程部分和Flow部分。在能够使用Flow之前,我们首先需要对协程有扎实的理解,因此先讲协程的内容。但如果您已有协程的经验,也可以直接开始学习Flow部分,然后根据需要回到协程部分的教程。 在协程部分,我们将详细了解Kotlin协程相较于其他异步编程方法(如RxJava和回调)的优势,然后讨论一些理论基础,包括:例程与协程、挂起函数、协程与线程、阻塞与挂起、多线程协程及其内部工作原理。接下来,我们将实现Kotlin协程在Android应用中的一些最常见的用例,包括:使用Retrofit进行网络请求、实现超时和重试、使用Room与协程等。为了提升学习体验,本课程还会通过一系列练习来挑战学员。 在Kotlin Flow部分,我们首先将涵盖基础知识,解答“什么是Flow?”并讨论反应式编程的优缺点。接着,我们将学习不同的Flow构建器和操作符,并在第一个真实的Flow用例中使用Flow创建实时股票跟踪功能。之后,将学习如何处理Flow中的异常和取消,并学习StateFlow和SharedFlow的相关概念,了解如何使协程具备生命周期感知能力。 本课程的最后一部分将着重于单元测试,编写所实现的协程用例的单元测试,并讨论测试相关概念。 通过本课程,您将对Kotlin协程和Flow有基础的理解,并能够编写可读且可维护的异步多线程Android应用程序。
Google recommends Kotlin Coroutines and Flow as the preferred solution for asynchronous programming on Android. Sooner or later, probably every Android developer will get in touch with these topics. This course will give you a deep understanding of Kotlin Coroutines and Flow and show how to implement the most common use cases for Android applications.This course consists of two big parts: The Coroutines part and the Flow part. Before being able to use Flows in our applications, we first need a solid understanding of Coroutines. That's why Coroutines are covered first. However, if you already have some experience with Coroutines, then you can also start with the Flow part right away, and jump back to lessons of the Coroutines part whenever needed. In the part about Coroutines, first, we will take a detailed look at the advantages of Kotlin Coroutines over other approaches for asynchronous programming, like RxJava and Callbacks.Then, we will talk about some theoretical fundamentals. These include:Routines vs. CoroutinesSuspend FunctionsCoroutines vs. ThreadsBlocking vs. SuspendingMultithreaded CoroutinesInternal workings Next, we will implement some of the most common use cases for Kotlin Coroutines in Android applications. These include: Performing network requests with Retrofit sequentially and concurrentlyImplementing Timeouts and RetriesUsing Room with CoroutinesPerforming background processing with CoroutinesContinuing Coroutine execution even when the user leaves the screen. To improve your learning experience, this course also challenges you with several exercises. Learning Coroutines can be overwhelming because you need to learn a lot of new concepts. However, we are going to start simple and as our use cases will get more and more complex, we will learn about new concepts step-by-step. These new concepts are:Coroutine Builders (launch, async, runBlocking)Coroutine ContextCoroutine DispatchersStructured ConcurrencyCoroutine Scopes (viewModelScope, lifecycleScope, GlobalScope)Jobs and SupervisorJobsscoping functions (coroutineScope{} and supervisorScope{})Cooperative CancellationNon-Cancellable CodeWe will also make a deep dive into Exception Handling and discuss concepts like: exception handling with try/catchexception handling with CoroutineExceptionHandlerswhen to use try/catch and when to use a CoroutineExceptionHandlerexception handling in Coroutines started with launch and asyncexception handling specifics of scoping functions coroutineScope{} and supervisorScope{}Unit Tests are very important for every codebase. In the course's final section, we will write unit tests for most of the coroutine-based use cases we implemented earlier. We will discuss concepts likeTestCoroutineDispatchercreating a JUnit4 Rule for testing coroutine-based coderunBlockingTest{} Coroutine Buildervirtual timeTesting sequential and concurrent executionTestCoroutineScopeIn the part about Kotlin Flow, we first cover all the basics. We will answer the question "What is a Flow?" and then we discuss the benefits and drawbacks of reactive programming. Afterward, we are going to have a look at different Flow builders and operators: basic flow buildersterminal operators terminal operator "launchIn()"terminal operator "asLiveData()"lifecycle operatorsintermediate operatorsIn our first real Flow use case, we use a Flow to create a live stock-tracking feature, that uses all the available basic flow components. In the next module, we will take a look at Exception Handling and Cancellation with Kotlin Flow. In the following module, you will learn about StateFlow and SharedFlow and the following concepts: how to make Coroutines lifecycle-aware with the "repeatOnLifecycle()" suspend functionHot Flows VS Cold FlowsConverting Flows to SharedFlows with the "shareIn()" operatorConverting Flows to StateFlows with the "stateIn()" operatorWhen to use SharedFlow and when to use StateFlowNext, you will learn about Channels, how they differ from hot flows, and when they are useful in Android Applications.By the end of this course, you will have a fundamental understanding of Kotlin Coroutines and Flows and be able to write readable and maintainable, asynchronous, and multithreaded Android Applications.