Group Group Group Group Group Group Group Group Group

Errata for Reactive Programming with Kotlin 1st Edition

Catch any bugs or typos for the 1st Edition of Reactive Programming with Kotlin.

Chapter 11:

On page 209 of the pdf, the PublishSubject create function should be called to create sourceObservable.

The line

val sourceObservable = PublishSubject<String>()

should instead be

val sourceObservable = PublishSubject.create<String>()

@macsimus Thank you for sharing this - much appreciated! :]

Hi, I noticed when reading this book, that the author has made a grave error in his/her use of Viewmodels. In chapter 4, Observables & Subjects in practice, the author has a method saveBitmapFromImageView(imageView: ImageView,context: Context): Observable<String> { } , takes a context param. This is explicitly highlighted as wrong in the Android documents… A ViewModel must never reference a view, or any class that may hold a reference to the activity context. If the [ ViewModel ] needs the Application context, for example to find a system service, it can extend the [ AndroidViewModel ] class and have a constructor that receives the Application in the constructor, since Application class extends Context . I feel like this needed highlighted and the text/code should be updated

So class signature should be:
class SharedViewModel(private val app: Application) : AndroidViewModel(app) { }

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

Great catch! You’re absolutely right, the linked code should be using the Application context, either in passed in via the activity or by using the AndroidViewModel. The code will be updated!