diff --git a/app/src/main/java/com/example/sprout/refactor/viewmodel/BaseViewModel.java b/app/src/main/java/com/example/sprout/refactor/viewmodel/BaseViewModel.java index b2c0c75..85d9c9f 100644 --- a/app/src/main/java/com/example/sprout/refactor/viewmodel/BaseViewModel.java +++ b/app/src/main/java/com/example/sprout/refactor/viewmodel/BaseViewModel.java @@ -10,6 +10,7 @@ import com.example.sprout.refactor.messengers.ToastMessenger; import io.reactivex.Observable; +import io.reactivex.disposables.CompositeDisposable; /** * Base ViewModel @@ -18,6 +19,7 @@ */ public abstract class BaseViewModel implements LifecycleObserver { + protected CompositeDisposable subscriptions = null; protected ToastMessenger toastMessanger = new ToastMessenger(); protected NavigationMessenger navigationMessenger = new NavigationMessenger(); @@ -31,10 +33,12 @@ @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) public void onResume() { + subscriptions = new CompositeDisposable(); } @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE) public void onPause() { + subscriptions.dispose(); } @OnLifecycleEvent(Lifecycle.Event.ON_STOP) @@ -45,7 +49,6 @@ public void onDestroy() { } - public Observable getToastMessanger() { return toastMessanger.getObservable(); }