Kotlin Tutorial - Kotlin at Light Speed, Part 5 - Functional Programming in Kotlin

Описание к видео Kotlin Tutorial - Kotlin at Light Speed, Part 5 - Functional Programming in Kotlin

blog post: https://blog.rockthejvm.com/kotlin-flows
Complete Kotlin course: https://rockthejvm.com/p/kotlin-essen...

This is a long-form practical introduction to Kotlin Flows, a reactive data structure that can emit values in an asynchronous, non-blocking fashion. This video will teach you how to build Kotlin Flows, how to manage their lifecycle, what to do in case your flows get empty or throw errors, how to transform Kotlin Flows with functional programming and more.

You will also learn how Flows give you a high degree of control over how coroutines evaluate and process their elements, and finally we will explore primitives for merging, concatenating and otherwise concurrently transform multiple flows as our application becomes more complex.

Timeline:
0:00 Intro
2:15 Building Flows
7:58 Flow Lifecycle
10:02 Error Handling and Retries
20:44 Transforming Flows
27:35 Flows and Coroutines
38:02 Merging and Concurrent Transformers

--------------------------------------------------------------------------
STARTER CODE
--------------------------------------------------------------------------

```
@JvmInline value class Id(val id: Int)
@JvmInline value class FirstName(val value: String)
@JvmInline value class LastName(val value: String)
data class Actor(val id: Id, val firstName: FirstName, val lastName: LastName) {
fun fullName() = firstName.value + " " + lastName.value
}

val henryCavill = Actor(Id(1), FirstName("Henry"), LastName("Cavill"))
val galGadot: Actor = Actor(Id(1), FirstName("Gal"), LastName("Gadot"))
val ezraMiller: Actor = Actor(Id(2), FirstName("Ezra"), LastName("Miller"))
val rayFisher: Actor = Actor(Id(3), FirstName("Ray"), LastName("Fisher"))
val benAffleck: Actor = Actor(Id(4), FirstName("Ben"), LastName("Affleck"))
val jasonMomoa: Actor = Actor(Id(5), FirstName("Jason"), LastName("Momoa"))

// The Avengers
val robertDowneyJr: Actor = Actor(Id(6), FirstName("Robert"), LastName("Downey Jr."))
val chrisEvans: Actor = Actor(Id(7), FirstName("Chris"), LastName("Evans"))
val markRuffalo: Actor = Actor(Id(8), FirstName("Mark"), LastName("Ruffalo"))
val chrisHemsworth: Actor = Actor(Id(9), FirstName("Chris"), LastName("Hemsworth"))
val scarlettJohansson: Actor = Actor(Id(10), FirstName("Scarlett"), LastName("Johansson"))
val jeremyRenner: Actor = Actor(Id(11), FirstName("Jeremy"), LastName("Renner"))

// Spider-Man
val tomHolland: Actor = Actor(Id(12), FirstName("Tom"), LastName("Holland"))
val tobeyMaguire: Actor = Actor(Id(13), FirstName("Tobey"), LastName("Maguire"))
val andrewGarfield: Actor = Actor(Id(14), FirstName("Andrew"), LastName("Garfield"))
```

Follow Rock the JVM on:
LinkedIn:   / rockthejvm  
Twitter:   / rockthejvm  
Blog: Blog: https://blog.rockthejvm.com

-------------------------------------------------------------------------
Home: https://rockthejvm.com
-------------------------------------------------------------------------

Комментарии

Информация по комментариям в разработке