Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Kotlin

You're reading from   Mastering Kotlin Learn advanced Kotlin programming techniques to build apps for Android, iOS, and the web

Arrow left icon
Product type Paperback
Published in Oct 2019
Publisher Packt
ISBN-13 9781838555726
Length 434 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Nate Ebel Nate Ebel
Author Profile Icon Nate Ebel
Nate Ebel
Arrow right icon
View More author details
Toc

Table of Contents (25) Chapters Close

Preface 1. Section 1: Kotlin – A Modern Solution to Application Development FREE CHAPTER
2. A New Challenger Approaches 3. Programmers' Multi-Tool – Flexible, Expressive, and Concise 4. Section 2: Putting the Pieces Together – Modeling Data, Managing State, and Application Architecture
5. Understanding Programming Paradigms in Kotlin 6. First-Class Functions 7. Modeling Real-World Data 8. Section 3: Play Nice – Integrating Kotlin With Existing Code
9. Interoperability as a Design Goal 10. Crossing Over – Working across Java and Kotlin 11. Controlling the Story 12. Baby Steps – Integration through Testing 13. Section 4: Go Beyond – Exploring Advanced and Experimental Language Features
14. Practical Concurrency 15. Building Your Own Tools – Domain-Specific Languages (DSLs) 16. Fully Functional – Embracing Functional Programming 17. Section 5: The Wide World of Kotlin – Using Kotlin across the Entire Development Stack
18. Kotlin on Android 19. Kotlin and Web Development 20. Introducing Multiplatform Kotlin 21. Taming the Monolith with Microservices 22. Practical Design Patterns 23. Assessments 24. Other Books You May Enjoy

Coroutines in practice

Now that we understand the foundations of coroutines, let's learn how to leverage coroutines with a view to handling async operations.

In this section, we'll explore the practical usage of coroutines in Kotlin. We'll examine the available primitives and we'll work through several examples. Finally, we'll examine some more advanced concepts, such as proper error handling and controlling coroutine scope.

Coroutine primitives

There are several fundamental concepts to understand when working with Kotlin coroutines. To highlight these, we can look at our example from the previous section:

fun main() {
GlobalScope.launch {
delay(500)
println("Coroutines"...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime