LifecycleDisposable
LifecycleDisposable dispose RxJava streams on lifecycle down event that corresponding to Activity/Fragment's lifecycle state when subscribe using Android Architecture Components Lifecycle.
Usage
Activity
Table 1 Corresponding between Activity's lifecycle state and Lifecycle down event.
Subscribe | Lifecycle.State | Lifecycle.Event | Dispose |
---|---|---|---|
onCreate | INITIALIZED | ON_DESTROY | onDestroy |
onStart | CREATED | ON_STOP | onStop |
onResume | STARTED | ON_PAUSE | onPause |
onPause | STARTED | ON_DESTROY | onDestroy |
onStop | CREATED | ON_DESTROY | onDestroy |
onDestroy | DESTROYED | ON_DESTROY | onDestroy |
Fragment
Table 2 Corresponding between Fragment's lifecycle state and Lifecycle down event.
Subscribe | Lifecycle.State | Lifecycle.Event | Dispose |
---|---|---|---|
onCreate | INITIALIZED | ON_DESTROY | onDestroy |
onCreateView | INITIALIZED | ON_DESTROY | onDestroyView |
onStart | CREATED | ON_STOP | onStop |
onResume | STARTED | ON_PAUSE | onPause |
onPause | STARTED | ON_DESTROY | onDestroyView |
onStop | CREATED | ON_DESTROY | onDestroyView |
onDestroyView | DESTROYED | ON_DESTROY | onDestroyView |
onDestroy | DESTROYED | ON_DESTROY | onDestroy |