Do We Really Want This?

LiveData was not set up to have a vast library of transformations, the way that RxJava has its vast library of operators. map() and switchMap() are almost afterthoughts. And while Google may not add many more transformations to the Transformations class, undoubtedly somebody will create a library with implementations of filter() and a handful of other RxJava-style operators.

However, those libraries will be limited, because LiveData itself is not as rich a framework as is RxJava. There is no notion in LiveData of propagating errors, or indicating that a stream is completed. Some RxJava operators will be difficult or impossible to implement as a result.

And this is by design.

LiveData is designed to be simple and lifecycle aware. That’s it. If your needs transcend what LiveData can handle well, consider migrating to RxJava. Conversely, if LiveData handles everything that you need, you can skip RxJava’s complexity.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.