# Reactive Programming with RxAndroid in Kotlin: An Introduction | raywenderlich.com

**URL:** <https://forums.kodeco.com/t/reactive-programming-with-rxandroid-in-kotlin-an-introduction-raywenderlich-com/72195>\
**Category:** 🎓 Courses & Articles\
**Created:** [May 28, 2019, 7:16am UTC](https://forums.kodeco.com/t/reactive-programming-with-rxandroid-in-kotlin-an-introduction-raywenderlich-com/72195 "2019-05-28T07:16:47Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![kandroidj](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/kandroidj/32/104975_2.png) [@kandroidj](https://forums.kodeco.com/u/kandroidj)\
**Post date:** [May 28, 2019, 7:16am UTC](https://forums.kodeco.com/t/reactive-programming-with-rxandroid-in-kotlin-an-introduction-raywenderlich-com/72195/1 "2019-05-28T07:16:47Z")

</div>

Learn about how Reactive programming is a whole new paradigm using RxJava and RxAndroid in Android with Kotlin.

* * *
This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/2071847-reactive-programming-with-rxandroid-in-kotlin-an-introduction](https://www.raywenderlich.com/2071847-reactive-programming-with-rxandroid-in-kotlin-an-introduction)

---

<div class="post-metadata">

**Author:** ![caipivara](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/caipivara/32/91795_2.png) [@caipivara](https://forums.kodeco.com/u/caipivara)\
**Post date:** [May 29, 2019, 6:32pm UTC](https://forums.kodeco.com/t/reactive-programming-with-rxandroid-in-kotlin-an-introduction-raywenderlich-com/72195/2 "2019-05-29T18:32:27Z")

</div>

You can use doFinally to dismiss the progress dialog, it is called if an item is emitted or on error.

---

<div class="post-metadata">

**Author:** ![lsteamer](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lsteamer/32/102075_2.png) [@lsteamer](https://forums.kodeco.com/u/lsteamer)\
**Post date:** [June 24, 2019, 12:23pm UTC](https://forums.kodeco.com/t/reactive-programming-with-rxandroid-in-kotlin-an-introduction-raywenderlich-com/72195/3 "2019-06-24T12:23:15Z")

</div>

This is a really good tutorial to finally get one’s head around Rx.

---

<div class="post-metadata">

**Author:** ![luckyplanet](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/luckyplanet/32/102449_2.png) [@luckyplanet](https://forums.kodeco.com/u/luckyplanet)\
**Post date:** [July 23, 2019, 9:34pm UTC](https://forums.kodeco.com/t/reactive-programming-with-rxandroid-in-kotlin-an-introduction-raywenderlich-com/72195/4 "2019-07-23T21:34:29Z")

</div>

I found a problem in the section for **Maybe**  
[https://www.raywenderlich.com/2071847-reactive-programming-with-rxandroid-in-kotlin-an-introduction#toc-anchor-016](https://www.raywenderlich.com/2071847-reactive-programming-with-rxandroid-in-kotlin-an-introduction#toc-anchor-016)

In the example, the last few lines look like this:

```auto
.subscribeOn(AndroidSchedulers.mainThread())
.subscribe {
   holder.itemView.imageFavorite.isChecked = it == 1 // 6
}

```

This causes an error:  
_io.reactivex.exceptions.OnErrorNotImplementedException: Only the original thread that created a view hierarchy can touch its views._

I think you want it to use `observeOn`, like this:

```auto
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
  holder.itemView.imageFavorite.isChecked = it == 1
}

```

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [August 22, 2019, 4:31am UTC](https://forums.kodeco.com/t/reactive-programming-with-rxandroid-in-kotlin-an-introduction-raywenderlich-com/72195/5 "2019-08-22T04:31:43Z")

</div>

@kandroidj Can you please help with this when you get a chance? Thank you - much appreciated! :]

---

<div class="post-metadata">

**Author:** ![rva5120](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/rva5120/32/81494_2.png) [@rva5120](https://forums.kodeco.com/u/rva5120)\
**Post date:** [September 20, 2019, 6:20pm UTC](https://forums.kodeco.com/t/reactive-programming-with-rxandroid-in-kotlin-an-introduction-raywenderlich-com/72195/6 "2019-09-20T18:20:19Z")

</div>

Hello! Thank you for this tutorial, it is a great way to get started with reactive programming 🙂

I found an issue on the section “Observe Button Clicks”. Here, we end with the app running database queries on the UI thread (which is what you intend). However, Android API 28 throws an IllegalStateException and does not let you execute the query at all (the app crashes when you press the button).  
A quick fix for this (before you show us how to use threading on the next section) is adding the modifying the code for building the database instance:

> INSTANCE = Room.databaseBuilder(context,  
> CheeseDatabase::class.java, “cheese.db”)**.allowMainThreadQueries()**  
> .build()

This allows you to see the progress so far.

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [October 15, 2019, 12:07am UTC](https://forums.kodeco.com/t/reactive-programming-with-rxandroid-in-kotlin-an-introduction-raywenderlich-com/72195/7 "2019-10-15T00:07:52Z")

</div>

@rva5120 Thank you for sharing your solution - much appreciated! :]

---

<div class="post-metadata">

**Author:** ![wasimsafdar](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/wasimsafdar/32/81494_2.png) [@wasimsafdar](https://forums.kodeco.com/u/wasimsafdar)\
**Post date:** [October 19, 2019, 10:36am UTC](https://forums.kodeco.com/t/reactive-programming-with-rxandroid-in-kotlin-an-introduction-raywenderlich-com/72195/8 "2019-10-19T10:36:40Z")

</div>

I am getting ‘Gradle project sync failed’ error after downloading ‘’ cheesefinder-starter" project. Cause of error is ‘org/gradle/internal/impldep/com/google/common/collect/Lists’. Anybody can help me to solve this issue?

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [November 14, 2019, 8:07pm UTC](https://forums.kodeco.com/t/reactive-programming-with-rxandroid-in-kotlin-an-introduction-raywenderlich-com/72195/9 "2019-11-14T20:07:20Z")

</div>

@kandroidj Do you have any feedback about this? Thank you - much appreciated! :]

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [January 14, 2020, 11:20pm UTC](https://forums.kodeco.com/t/reactive-programming-with-rxandroid-in-kotlin-an-introduction-raywenderlich-com/72195/10 "2020-01-14T23:20:51Z")

</div>

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [January 14, 2020, 11:20pm UTC](https://forums.kodeco.com/t/reactive-programming-with-rxandroid-in-kotlin-an-introduction-raywenderlich-com/72195/11 "2020-01-14T23:20:55Z")

</div>

Closed on January 14, 2020, 11:20pm UTC


