public final class AndroidObservable
extends java.lang.Object
| 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).
|
static <T> rx.Observable<T> |
fromActivity(android.app.Activity activity,
rx.Observable<T> sourceObservable)
Deprecated.
|
static rx.Observable<android.content.Intent> |
fromBroadcast(android.content.Context context,
android.content.IntentFilter filter)
Create Observable that wraps BroadcastReceiver and emmit received intents.
|
static rx.Observable<android.content.Intent> |
fromBroadcast(android.content.Context context,
android.content.IntentFilter filter,
java.lang.String broadcastPermission,
android.os.Handler schedulerHandler)
Create Observable that wraps BroadcastReceiver and emmit received intents.
|
static <T> rx.Observable<T> |
fromFragment(java.lang.Object fragment,
rx.Observable<T> sourceObservable)
Deprecated.
|
static rx.Observable<android.content.Intent> |
fromLocalBroadcast(android.content.Context context,
android.content.IntentFilter filter)
Create Observable that wraps BroadcastReceiver and connects to LocalBroadcastManager
to emmit received intents.
|
@Deprecated
public static <T> rx.Observable<T> fromActivity(android.app.Activity activity,
rx.Observable<T> sourceObservable)
AndroidObservable.bindActivity(android.app.Activity, rx.Observable) insteadobserveOn(AndroidSchedulers.mainThread()),
but this behavior may change in the future, so it is encouraged to use this wrapper instead.
You must unsubscribe from the returned observable in onDestroy to not leak the given Activity.
Ex.:
// in any Activity
mSubscription = fromActivity(this, Observable.just("value")).subscribe(...);
// in onDestroy
mSubscription.unsubscribe();
T - activity - the activity in which the source observable will be observedsourceObservable - the observable sequence to observe from the given Activity@Deprecated
public static <T> rx.Observable<T> fromFragment(java.lang.Object fragment,
rx.Observable<T> sourceObservable)
AndroidObservable.bindFragment(Object, rx.Observable) insteadonDestroy to not leak the given fragment.
Ex.:
// in any Fragment
mSubscription = fromFragment(this, Observable.just("value")).subscribe(...);
// in onDestroy
mSubscription.unsubscribe();
T - fragment - the fragment in which the source observable will be observedsourceObservable - the observable sequence to observe from the given fragmentpublic static <T> rx.Observable<T> bindActivity(android.app.Activity activity,
rx.Observable<T> source)
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)
fragment - the fragment to bind the source sequence tosource - the source sequencepublic static rx.Observable<android.content.Intent> fromBroadcast(android.content.Context context,
android.content.IntentFilter filter)
filter - Selects the Intent broadcasts to be received.public static rx.Observable<android.content.Intent> fromBroadcast(android.content.Context context,
android.content.IntentFilter filter,
java.lang.String broadcastPermission,
android.os.Handler schedulerHandler)
filter - Selects the Intent broadcasts to be received.broadcastPermission - String naming a permissions that a
broadcaster must hold in order to send an Intent to you. If null,
no permission is required.schedulerHandler - Handler identifying the thread that will receive
the Intent. If null, the main thread of the process will be used.public static rx.Observable<android.content.Intent> fromLocalBroadcast(android.content.Context context,
android.content.IntentFilter filter)
filter - Selects the Intent broadcasts to be received.