public class RxLifecycleAndroid
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <T> com.trello.rxlifecycle4.LifecycleTransformer<T> |
bindActivity(io.reactivex.rxjava3.core.Observable<ActivityEvent> lifecycle)
Binds the given source to an Activity lifecycle.
|
static <T> com.trello.rxlifecycle4.LifecycleTransformer<T> |
bindFragment(io.reactivex.rxjava3.core.Observable<FragmentEvent> lifecycle)
Binds the given source to a Fragment lifecycle.
|
static <T> com.trello.rxlifecycle4.LifecycleTransformer<T> |
bindView(android.view.View view)
Binds the given source to a View lifecycle.
|
@NonNull
@CheckResult
public static <T> com.trello.rxlifecycle4.LifecycleTransformer<T> bindActivity(@NonNull
io.reactivex.rxjava3.core.Observable<ActivityEvent> lifecycle)
This helper automatically determines (based on the lifecycle sequence itself) when the source should stop emitting items. In the case that the lifecycle sequence is in the creation phase (CREATE, START, etc) it will choose the equivalent destructive phase (DESTROY, STOP, etc). If used in the destructive phase, the notifications will cease at the next event; for example, if used in PAUSE, it will unsubscribe in STOP.
Due to the differences between the Activity and Fragment lifecycles, this method should only be used for an Activity lifecycle.
lifecycle - the lifecycle sequence of an ActivityLifecycleTransformer that unsubscribes the source during the Activity lifecycle@NonNull
@CheckResult
public static <T> com.trello.rxlifecycle4.LifecycleTransformer<T> bindFragment(@NonNull
io.reactivex.rxjava3.core.Observable<FragmentEvent> lifecycle)
This helper automatically determines (based on the lifecycle sequence itself) when the source should stop emitting items. In the case that the lifecycle sequence is in the creation phase (CREATE, START, etc) it will choose the equivalent destructive phase (DESTROY, STOP, etc). If used in the destructive phase, the notifications will cease at the next event; for example, if used in PAUSE, it will unsubscribe in STOP.
Due to the differences between the Activity and Fragment lifecycles, this method should only be used for a Fragment lifecycle.
lifecycle - the lifecycle sequence of a FragmentLifecycleTransformer that unsubscribes the source during the Fragment lifecycle@NonNull
@CheckResult
public static <T> com.trello.rxlifecycle4.LifecycleTransformer<T> bindView(@NonNull
android.view.View view)
Specifically, when the View detaches from the window, the sequence will be completed.
Warning: you should make sure to use the returned Transformer on the main thread, since we're binding to a View (which only allows binding on the main thread).
view - the view to bind the source sequence toLifecycleTransformer that unsubscribes the source during the View lifecycle