I'm new to RxJava and LeakCanary so this might be something simple (hopefully).
Essentially I have an Activity which includes a
CompositeDisposable
Completable
CompositeDisposable
CompositeDisposable
Completable
AndroidViewModel
private CompositeDisposable mSubscriptions;
@Override
public void onCreate(Bundle savedInstanceState) {
...
mSubscriptions = new CompositeDisposable();
...
}
@Override
protected void onPause() {
super.onPause();
mSubscriptions.clear();
}
public void someMethodForButtonClick(View view) {
IwcRepository iwcRepository =
Injection.provideIwcRepository(getApplication());
mSubscriptions.add(iwcRepository.getSomeCompletable()
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableCompletableObserver() {
@Override
public void onComplete() {
}
@Override
public void onError(@NonNull Throwable e) {
}
}));
}
Ok so as mentioned in the comments I resolved this error by removing the CompositeDisposable from the repository. New to RxJava I didn't know how to use it properly. I had subscriptions inside subscriptions rather than chaining and returning one observable, and subscribing once at the end of the chain. I.e. my repository didn't actually need to subscribe to anything, it just needed to tack on some logic or do some "andThen's".