package nucleus.presenter.delivery;

import rx.Notification;
import rx.Observable;
import rx.functions.Func1;

public class DeliverFirst<View, T> implements Observable.Transformer<T, Delivery<View, T>> {

    private final Observable<View> view;

    public DeliverFirst(Observable<View> view) {
        this.view = view;
    }

    @Override
    public Observable<Delivery<View, T>> call(Observable<T> observable) {
        return observable.materialize()
            .take(1)
            .switchMap(new Func1<Notification<T>, Observable<? extends Delivery<View, T>>>() {
                @Override
                public Observable<? extends Delivery<View, T>> call(final Notification<T> notification) {
                    return view.map(new Func1<View, Delivery<View, T>>() {
                        @Override
                        public Delivery<View, T> call(View view) {
                            return view == null ? null : new Delivery<>(view, notification);
                        }
                    });
                }
            })
            .take(1);
    }
}

@@ -1050,16 +1050,248 @@
      %7D)%0A
+            .filter(new Func1%3CDelivery%3CView, T%3E, Boolean%3E() %7B%0A                @Override%0A                public Boolean call(Delivery%3CView, T%3E delivery) %7B%0A                    return delivery != null;%0A                %7D%0A            %7D)%0A
         

Add missing filter call to DeliverFirst