package io.sweers.catchup.rx.boundlifecycle.observers;

import io.reactivex.Maybe;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.sweers.catchup.rx.boundlifecycle.LifecycleProvider;

/**
 * Created by pandanomic to 12/3/16.
 */
public class BoundObservers2 {

  private Maybe<?> lifecycle;

  public static BoundObservers2 against(LifecycleProvider<?> provider) {
    return new BoundObservers2(provider);
  }

  public static BoundObservers2 against(Observable<?> lifecycle) {
    return new BoundObservers2(lifecycle);
  }

  <E> BoundObservers2(LifecycleProvider<E> provider) {
    this.lifecycle = BaseObserver.mapEvents(provider.lifecycle(), provider.correspondingEvents());
  }

  <E> BoundObservers2(Observable<E> lifecycle) {
    this.lifecycle = lifecycle.firstElement();
  }

  <E> BoundObservers2(Maybe<E> lifecycle) {
    this.lifecycle = lifecycle;
  }

  public <T> Observer<T> around(Observer<T> o) {
    return new BoundObserver.BoundObserverCreator<T>(lifecycle).around(o);
  }
}

@@ -536,32 +536,142 @@
 ifecycle);%0A  %7D%0A%0A
+  public static BoundObservers2 against(Maybe%3C?%3E lifecycle) %7B%0A    return new BoundObservers2(lifecycle);%0A  %7D%0A%0A
   %3CE%3E BoundObser

Add Maybe lifecycle override