I am learning a rather huge code base and.... well.
Reactive programming is a design paradigm that handles real-time updates to otherwise static content using asynchronous programming logic. It provides an efficient method for handling data updates to content whenever a user makes an inquiry (via automated data streams).
Imperative vs Reactive
Reactive programming is declarative as opposed to imperative.
Imperative programming is programming "how to do something"
Imperative example
val result = mutableListOf<Int>()
for (i in 1..5) {
result.add(i)
}
println("result is $result")
Reactive example
val result = (1..5).map { it }
println("Declaritive result $result")
From the examples, if imperative programming is food recipe, then reactive programming is ordering food!
Kotlin collections api
Kotlin collections api makes reactive programming easy as knowledge of the existence. There are about 200 of them.
Top comments (0)