public final class AppObservable
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static boolean |
USES_SUPPORT_FRAGMENTS |
Modifier and Type | Method and Description |
---|---|
static <T> rx.Observable<T> |
bindActivity(android.app.Activity activity,
rx.Observable<T> source)
Binds the given source sequence to an activity.
|
static <T> rx.Observable<T> |
bindFragment(java.lang.Object fragment,
rx.Observable<T> source)
Binds the given source sequence to a fragment (native or support-v4).
|
public static <T> rx.Observable<T> bindActivity(android.app.Activity activity, rx.Observable<T> source)
This helper will schedule the given sequence to be observed on the main UI thread and ensure that no notifications will be forwarded to the activity in case it is scheduled to finish.
You should unsubscribe from the returned Observable in onDestroy at the latest, in order to not leak the activity or an inner subscriber. Conversely, when the source sequence can outlive the activity, make sure to bind to new instances of the activity again, e.g. after going through configuration changes. Refer to the samples project for actual examples.
activity
- the activity to bind the source sequence tosource
- the source sequencepublic static <T> rx.Observable<T> bindFragment(java.lang.Object fragment, rx.Observable<T> source)
This helper will schedule the given sequence to be observed on the main UI thread and ensure that no notifications will be forwarded to the fragment in case it gets detached from its activity or the activity is scheduled to finish.
You should unsubscribe from the returned Observable in onDestroy for normal fragments, or in onDestroyView for retained fragments, in order to not leak any references to the host activity or the fragment. Refer to the samples project for actual examples.
fragment
- the fragment to bind the source sequence tosource
- the source sequence