Added LifecycleObservable binds

This is the first half of the puzzle that is #12. It provides two main facilities:

- `LifecycleObservable.bindUntilLifecycleEvent()` lets you specify an exact point in a lifecycle to unsubscribe at.

- `LifecycleObservable.bindActivityLifecycle()` and `bindFragmentLifecycle()` which make a best effort guess at when you want a subscription to end, based on the lifecycle state.

Implementation detail: `OperatorSubscribeUntil` acts like `takeUntil()`, except that it unsubscribes instead of calling `onComplete()` when the conditional `Observable` emits an item.

If this works then we can later figure out how to create these `Observable<LifecycleEvent>` streams.
That sounds sensible +1

@dlew do you wanna take a stab at this as part of this PR, otherwise we can
do it in a separate step

On Mon, Nov 24, 2014 at 11:16 AM, Roman Mazur <notifications@github.com>
wrote:

> In rxandroid/src/main/java/rx/android/lifecycle/LifecycleObservable.java:
>
> > +        throw new AssertionError("LifeCycleObservable cannot be instantiated.");
> > +    }
> > +
> > +    /**
> > +     * Binds the given source to a lifecycle.
> > +     * <p/>
> > +     * When the lifecycle event occurs, the source will cease to receive any notifications.
> > +     *
> > +     * @param lifecycle the lifecycle sequence
> > +     * @param source    the source sequence
> > +     * @param event     the event which should conclude notifications to the source
> > +     */
> > +    public static <T> Observable<T> bindUntilLifecycleEvent(Observable<LifecycleEvent> lifecycle,
> > +                                                            Observable<T> source,
> > +                                                            final LifecycleEvent event) {
> > +        if (lifecycle == null || source == null) {
>
> Since it's an Android library, we can use Android support annotations
> <http://tools.android.com/tech-docs/support-annotations>.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/ReactiveX/RxAndroid/pull/75/files#r20781487>.
>



-- 

Matthias Käppler

*Engineer*


Twitter: https://twitter.com/mttkay

Skype: matthias-sc



SoundCloud Ltd. | Rheinsberger Str. 76/77, 10115 Berlin, Germany | +49
(0)172 2345679

Managing Director: Alexander Ljung | Incorporated in England & Wales
with Company
No. 6343600 | Local Branch Office | AG Charlottenburg  | HRB 110657B



Capture and share your music & audio on SoundCloud
<http://soundcloud.com/creators>