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


Java PublishSubject.asObservable方法代碼示例

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


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

示例1: start

import rx.subjects.PublishSubject; //導入方法依賴的package包/類
@NonNull
@Override
public Observable<Long> start() {
    final PublishSubject<Long> tickPublisher = PublishSubject.create();

    Subscription subscription = serviceConnectionSubject.subscribe(
            // The action to take `onNext`, i.e., when `onServiceConnected` is called.
            remoteStopwatchService -> {
                try {
                    // Start the remote stopwatch, which is owned by the remote Service
                    // Passing in the listener for `tick` events to communicate back across process boundaries.
                    remoteStopwatchService.start(new IStopwatchTickListener.Stub() {

                        @Override
                        public void onTick(long tick) throws RemoteException {
                            tickPublisher.onNext(tick);
                        }
                    });
                } catch (RemoteException e) {
                    LogUtil.e(TAG, "RemoteException");
                    onError(e);
                }
            }, this::onError, this::onComplete);

    subscriptions.add(subscription);
    return tickPublisher.asObservable();
}
 
開發者ID:autonomousapps,項目名稱:ReactiveStopwatch,代碼行數:28,代碼來源:RemoteStopwatch.java

示例2: recyclerEventObservable

import rx.subjects.PublishSubject; //導入方法依賴的package包/類
@Provides
@PerFragment
public static Observable<RecyclerEvent> recyclerEventObservable(PublishSubject<RecyclerEvent> events) {
    return events.asObservable();
}
 
開發者ID:st1hy,項目名稱:Red-Calorie,代碼行數:6,代碼來源:IngredientsFragmentModule.java

示例3: menuActionObservable

import rx.subjects.PublishSubject; //導入方法依賴的package包/類
@Provides
public static Observable<AddIngredientMenuAction> menuActionObservable(
        PublishSubject<AddIngredientMenuAction> subject) {
    return subject.asObservable();
}
 
開發者ID:st1hy,項目名稱:Red-Calorie,代碼行數:6,代碼來源:AddIngredientFragmentModule.java

示例4: menuActionObservable

import rx.subjects.PublishSubject; //導入方法依賴的package包/類
@Provides
public static Observable<AddMealMenuAction> menuActionObservable(
        PublishSubject<AddMealMenuAction> actionPublishSubject) {
    return actionPublishSubject.asObservable();
}
 
開發者ID:st1hy,項目名稱:Red-Calorie,代碼行數:6,代碼來源:AddMealFragmentModule.java


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