ylliX - Online Advertising Network

Disposables Can Cause Memory Leaks

02 Feb 2021 • 3 min read Every Disposable holds a strong reference to the observer it binds. This can lead to surprising memory leaks. Consider the following example: class TacoViewModel : ViewModel() { var compositeDisposable = CompositeDisposable() fun loadTaco(activity: Activity) { compositeDisposable.add( Single.just(Taco()) .subscribe { taco -> // Handle taco… println(“Taco created in […]

Simplifying DiffUtil with RxJava

One of my favorite parts of RxJava is that no matter how complex a state management usecase is, there’s always an operator for that™. During a recent code cleanup, I found a very cool usecase of RxJava’s scan() and compose() operators for simplifying the usually verbose DiffUtil implementation. I had been delaying writing this post […]