當前位置: 首頁>>代碼示例>>Java>>正文


Java Observer.onSubscribe方法代碼示例

本文整理匯總了Java中io.reactivex.Observer.onSubscribe方法的典型用法代碼示例。如果您正苦於以下問題:Java Observer.onSubscribe方法的具體用法?Java Observer.onSubscribe怎麽用?Java Observer.onSubscribe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.reactivex.Observer的用法示例。


在下文中一共展示了Observer.onSubscribe方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: subscribeActual

import io.reactivex.Observer; //導入方法依賴的package包/類
@Override
protected void subscribeActual(
    Observer<? super ObservableArrayListItemRangeRemovalEvent<T>> observer) {
  if (!checkMainThread(observer)) {
    return;
  }
  Listener listener = new Listener(observableArrayList, observer);
  observer.onSubscribe(listener);
  observableArrayList.addOnListChangedCallback(listener.onListChangedCallback);
}
 
開發者ID:oldergod,項目名稱:RxDataBinding,代碼行數:11,代碼來源:ObservableArrayListItemRangeRemovalEventObservable.java

示例2: subscribeActual

import io.reactivex.Observer; //導入方法依賴的package包/類
@Override protected void subscribeActual(Observer<? super Long> observer) {
  if (!checkMainThread(observer)) {
    return;
  }
  Listener listener = new Listener(observableLong, observer);
  observer.onSubscribe(listener);
  observableLong.addOnPropertyChangedCallback(listener.onPropertyChangedCallback);
}
 
開發者ID:oldergod,項目名稱:RxDataBinding,代碼行數:9,代碼來源:ObservableLongObservable.java

示例3: subscribeActual

import io.reactivex.Observer; //導入方法依賴的package包/類
@Override
protected void subscribeActual(Observer<? super Event> observer) {
	if (!Preconditions.checkDisplay(observer, display)) {
		return;
	}
	DisplayListener listener = new DisplayListener(display, eventType, observer);
	observer.onSubscribe(listener);
	display.addListener(SWT.Dispose, e -> listener.dispose());
	addlistener(listener);
}
 
開發者ID:SimonScholz,項目名稱:RxSWT,代碼行數:11,代碼來源:DisplayObservable.java

示例4: subscribeActual

import io.reactivex.Observer; //導入方法依賴的package包/類
@Override
protected void subscribeActual(Observer<? super StateChangeEvent> observer) {
    if (!Preconditions.checkMainThread(observer)) {
        return;
    }
    Listener listener = new Listener(button, observer);
    observer.onSubscribe(listener);
    button.setOnStateChangeListener(listener);
}
 
開發者ID:dewarder,項目名稱:CameraButton,代碼行數:10,代碼來源:StateChangeEventObservable.java

示例5: subscribeActual

import io.reactivex.Observer; //導入方法依賴的package包/類
@Override protected void subscribeActual(Observer<? super Response<T>> observer) {
  // Since Call is a one-shot type, clone it for each new observer.
  Call<T> call = originalCall.clone();
  CallCallback<T> callback = new CallCallback<>(call, observer);
  observer.onSubscribe(callback);
  call.enqueue(callback);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:8,代碼來源:CallEnqueueObservable.java

示例6: subscribeActual

import io.reactivex.Observer; //導入方法依賴的package包/類
@Override
protected void subscribeActual(Observer<? super Response<T>> observer) {
    // Since Call is a one-shot type, clone it for each new observer.
    Call<T> call = originalCall.clone();
    observer.onSubscribe(new CallDisposable(call));

    boolean terminated = false;
    try {
        Response<T> response = call.execute();
        if (!call.isCanceled()) {
            observer.onNext(response);
        }
        if (!call.isCanceled()) {
            terminated = true;
            observer.onComplete();
        }
    } catch (Throwable t) {
        Exceptions.throwIfFatal(t);
        if (terminated) {
            RxJavaPlugins.onError(t);
        } else if (!call.isCanceled()) {
            try {
                observer.onError(t);
            } catch (Throwable inner) {
                Exceptions.throwIfFatal(inner);
                RxJavaPlugins.onError(new CompositeException(t, inner));
            }
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:31,代碼來源:CallExecuteObservable.java

示例7: subscribeActual

import io.reactivex.Observer; //導入方法依賴的package包/類
@Override protected void subscribeActual(Observer<? super Boolean> observer) {
  if (!checkMainThread(observer)) {
    return;
  }
  Listener listener = new Listener(observableBoolean, observer);
  observer.onSubscribe(listener);
  observableBoolean.addOnPropertyChangedCallback(listener.onPropertyChangedCallback);
}
 
開發者ID:oldergod,項目名稱:RxDataBinding,代碼行數:9,代碼來源:ObservableBooleanObservable.java

示例8: subscribeActual

import io.reactivex.Observer; //導入方法依賴的package包/類
@Override
protected void subscribeActual(
    Observer<? super ObservableArrayListItemRangeChangeEvent<T>> observer) {
  if (!checkMainThread(observer)) {
    return;
  }
  Listener listener = new Listener(observableArrayList, observer);
  observer.onSubscribe(listener);
  observableArrayList.addOnListChangedCallback(listener.onListChangedCallback);
}
 
開發者ID:oldergod,項目名稱:RxDataBinding,代碼行數:11,代碼來源:ObservableArrayListItemRangeChangeEventObservable.java

示例9: subscribeActual

import io.reactivex.Observer; //導入方法依賴的package包/類
@Override
protected void subscribeActual(Observer<? super DisposeEvent> observer) {
	if (!Preconditions.checkWidget(observer, widget)) {
		return;
	}
	RxDisposeListener listener = new RxDisposeListener(widget, observer);
	observer.onSubscribe(listener);
	widget.addDisposeListener(e -> listener.dispose());
	widget.addDisposeListener(listener);
}
 
開發者ID:SimonScholz,項目名稱:RxSWT,代碼行數:11,代碼來源:DisposeObservable.java

示例10: wrapObserver

import io.reactivex.Observer; //導入方法依賴的package包/類
public static <T> Observer<T> wrapObserver(Observer<T> observer, IRxBusQueue isResumedProvider)
{
    return new Observer<T>()
    {
        @Override
        public void onSubscribe(Disposable d) {
            observer.onSubscribe(d);
        }

        @Override
        public void onComplete()
        {
            observer.onComplete();
        }

        @Override
        public void onError(Throwable e)
        {
            observer.onError(e);
        }

        @Override
        public void onNext(T t)
        {
            if (RxUtil.safetyQueueCheck(t, isResumedProvider))
                observer.onNext(t);
        }
    };
}
 
開發者ID:MFlisar,項目名稱:RxBus2,代碼行數:30,代碼來源:RxSubscriptionUtil.java

示例11: wrapObserver

import io.reactivex.Observer; //導入方法依賴的package包/類
public static <T> Observer<T> wrapObserver(Observer<T> observer, IRxBusQueue isResumedProvider)
{
    return new Observer<T>()
    {
        @Override
        public void onSubscribe(Disposable d) {
            observer.onSubscribe(d);
        }

        @Override
        public void onComplete()
        {
            observer.onComplete();
        }

        @Override
        public void onError(Throwable e)
        {
            observer.onError(e);
        }


        @Override
        public void onNext(T t)
        {
            if (RxUtil.safetyQueueCheck(t, isResumedProvider))
                observer.onNext(t);
        }
    };
}
 
開發者ID:MFlisar,項目名稱:RxBus2,代碼行數:31,代碼來源:RxBusUtil.java

示例12: wrap

import io.reactivex.Observer; //導入方法依賴的package包/類
/**
 * @see Observable#subscribe(Observer)
 */
public <T> Observer<? super T> wrap(final Observer<? super T> observer) {
    LambdaObserver<? super T> disposableObserver = new LambdaObserver<>(
            new Consumer<T>() {
                @Override
                public void accept(T t) throws Exception {
                    observer.onNext(t);
                }
            },
            new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    observer.onError(throwable);
                }
            },
            new Action() {
                @Override
                public void run() throws Exception {
                    observer.onComplete();
                }
            },
            new Consumer<Disposable>() {
                @Override
                public void accept(Disposable disposable) throws Exception {
                    observer.onSubscribe(disposable);
                }
            }
    );

    return handleObserver(disposableObserver);
}
 
開發者ID:jzallas,項目名稱:RxDisposal,代碼行數:34,代碼來源:SubscriptionDecorator.java

示例13: subscribeActual

import io.reactivex.Observer; //導入方法依賴的package包/類
@Override
protected void subscribeActual(Observer<? super TapEvent> observer) {
    if (!Preconditions.checkMainThread(observer)) {
        return;
    }
    Listener listener = new Listener(button, observer);
    observer.onSubscribe(listener);
    button.setOnTapEventListener(listener);
}
 
開發者ID:dewarder,項目名稱:CameraButton,代碼行數:10,代碼來源:TapEventObservable.java

示例14: testWrapObserver

import io.reactivex.Observer; //導入方法依賴的package包/類
@Test
public void testWrapObserver() throws Exception {
    String testString = "test";
    Throwable testThrowable = mock(Throwable.class);
    Disposable testDisposable = mock(Disposable.class);

    Observer<? super String> testObserver = mockSubscriptionDecorator.wrap(mockObserver);
    validateDisposableDelegated(testObserver);

    testObserver.onNext(testString);
    verify(mockObserver, times(1))
            .onNext(testString);

    testObserver.onError(testThrowable);
    verify(mockObserver, times(1))
            .onError(testThrowable);

    testObserver = mockSubscriptionDecorator.wrap(mockObserver);

    testObserver.onComplete();
    verify(mockObserver, times(1))
            .onComplete();

    testObserver = mockSubscriptionDecorator.wrap(mockObserver);

    testObserver.onSubscribe(testDisposable);
    verify(mockObserver, times(1))
            .onSubscribe(argThat(validateDisposeIsDelegated(testDisposable)));
}
 
開發者ID:jzallas,項目名稱:RxDisposal,代碼行數:30,代碼來源:SubscriptionDecoratorTest.java

示例15: subscribeActual

import io.reactivex.Observer; //導入方法依賴的package包/類
@Override
protected void subscribeActual(Observer<? super MouseEvent> observer) {
	if (!Preconditions.checkWidget(observer, control)) {
		return;
	}
	RxMouseMoveListener listener = getMouseListener(control, observer);
	observer.onSubscribe(listener);
	control.addDisposeListener(e -> listener.dispose());
	control.addMouseMoveListener(listener);

}
 
開發者ID:SimonScholz,項目名稱:RxSWT,代碼行數:12,代碼來源:MouseMoveObservable.java


注:本文中的io.reactivex.Observer.onSubscribe方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。