When to dispose RxJava2 Disposable in ViewModel? : <p>I'm using <a href="https://developer.android.com/topic/libraries/architecture/viewmodel.html" rel="noreferrer">ViewModel</a> from Android Architecture Components in my app. In the ViewModel, I'm using <a href="https://github.com/ReactiveX/RxJava" rel="noreferrer">RxJava2</a> subscription and I keep <code>Disposable</code> object after I subscribe. Before, when I did this in <code>Activity</code>, I was used to dispose the <code>Disposable</code> in <code>onDestroy()</code> - to avoid memory leaks:</p>

<pre><code>@Override
protected void onDestroy() {
    disposable.dispose();
    super.onDestroy();
}
</code></pre>

<p>When and how should I dispose it in <code>ViewModel</code>? Do I actually need to do that?</p>
