当前位置: 首页>>代码示例>>Java>>正文


Java CompletableObserver类代码示例

本文整理汇总了Java中io.reactivex.CompletableObserver的典型用法代码示例。如果您正苦于以下问题:Java CompletableObserver类的具体用法?Java CompletableObserver怎么用?Java CompletableObserver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CompletableObserver类属于io.reactivex包,在下文中一共展示了CompletableObserver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCompletableObserver

import io.reactivex.CompletableObserver; //导入依赖的package包/类
private CompletableObserver getCompletableObserver() {
    return new CompletableObserver() {
        @Override
        public void onSubscribe(Disposable d) {
            Log.d(TAG, " onSubscribe : " + d.isDisposed());
        }

        @Override
        public void onComplete() {
            textView.append(" onComplete");
            textView.append(AppConstant.LINE_SEPARATOR);
            Log.d(TAG, " onComplete");
        }

        @Override
        public void onError(Throwable e) {
            textView.append(" onError : " + e.getMessage());
            textView.append(AppConstant.LINE_SEPARATOR);
            Log.d(TAG, " onError : " + e.getMessage());
        }
    };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:CompletableObserverExampleActivity.java

示例2: subscribeActual

import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Override
protected void subscribeActual(final CompletableObserver completableObserver) {
    verifyMainThread();
    final View view = viewWeakRef.get();
    if (view == null) {
        completableObserver.onComplete();
        return;
    }

    final ViewPropertyAnimatorCompat animator = ViewCompat.animate(view);

    completableObserver.onSubscribe(createAnimationDisposable(animator, onAnimationCancelAction));

    if (preTransformActions != null) {
        applyActions(preTransformActions, animator);
        animator.setDuration(NONE).setStartDelay(NONE)
                .withEndAction(() -> runAnimation(completableObserver, animator))
                .start();
    } else {
        runAnimation(completableObserver, animator);
    }
}
 
开发者ID:0ximDigital,项目名称:Rx2Animations,代码行数:23,代码来源:AnimateCompletable.java

示例3: onDeleteCheckPoint

import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Override public void onDeleteCheckPoint(int adapterPosition) {
  getCheckPointDataSource().deleteCheckPoint(allCheckPoints.get(adapterPosition))
      .subscribeOn(Schedulers.io())
      .observeOn(AndroidSchedulers.mainThread())
      .subscribeWith(new CompletableObserver() {
        @Override public void onSubscribe(Disposable d) {

        }

        @Override public void onComplete() {
          allCheckPoints.remove(adapterPosition);
          getView().removeMarker(adapterPosition);
          getView().notifyListAdapter();
        }

        @Override public void onError(Throwable e) {
          getView().showError("Delete Failed");
        }
      });
}
 
开发者ID:Arjun-sna,项目名称:LocationAware,代码行数:21,代码来源:LocationAlarmPresenter.java

示例4: subscribeActual

import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Override
protected void subscribeActual(CompletableObserver s) {
    CompletableObserver observer;
    try {
        observer = ObjectHelper.requireNonNull(s, "Null Observer");
    } catch (Throwable e) {
        Exceptions.throwIfFatal(e);
        // can't call onError because no way to know if a Disposable has been set or not
        // can't call onSubscribe because the call might have set a Disposable already
        RxJavaPlugins.onError(e);

        NullPointerException npe = new NullPointerException("Actually not, but can't throw other exceptions due to RS");
        npe.initCause(e);
        throw npe;
    }

    source.subscribe(new AttachCompletableObserver(observer, this.compositeDisposable));
}
 
开发者ID:cp949,项目名称:DisposableAttach,代码行数:19,代码来源:AttachDisposableCompletable.java

示例5: subscribeActual

import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Override
protected void subscribeActual(CompletableObserver observer) {
    boolean b;

    try {
        b = condition.getAsBoolean();
    } catch (Throwable ex) {
        EmptyDisposable.error(ex, observer);
        return;
    }

    if (b) {
        then.subscribe(observer);
    } else {
        orElse.subscribe(observer);
    }
}
 
开发者ID:fengzhizi715,项目名称:RxConditions,代码行数:18,代码来源:CompletableIfThen.java

示例6: getObserver

import io.reactivex.CompletableObserver; //导入依赖的package包/类
private CompletableObserver getObserver() {
    return new CompletableObserver() {

        @Override
        public void onSubscribe(Disposable d) {
            Log.d(TAG, " onSubscribe : " + d.isDisposed());
        }

        @Override
        public void onError(Throwable e) {
            textView.append(" onError : " + e.getMessage());
            textView.append(AppConstant.LINE_SEPARATOR);
            Log.d(TAG, " onError : " + e.getMessage());
        }

        @Override
        public void onComplete() {
            textView.append(" onComplete");
            textView.append(AppConstant.LINE_SEPARATOR);
            Log.d(TAG, " onComplete");
        }
    };
}
 
开发者ID:changjiashuai,项目名称:RxJava2-Android-Sample,代码行数:24,代码来源:IgnoreElementsExampleActivity.java

示例7: apply

import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Override
public CompletableObserver apply(CompletableObserver observer) throws Exception {
    return new DisposableCompletableObserver() {
        @Override
        public void onComplete() {
            if (!isDisposed()) {
                observer.onError(throwable);
            }
        }

        @Override
        public void onError(Throwable ex) {
            if (!isDisposed()) {
                observer.onError(ex);
            }
        }
    };
}
 
开发者ID:TrustWallet,项目名称:trust-wallet-android,代码行数:19,代码来源:CompletableErrorProxyOperator.java

示例8: failOrCountDownCompletableObserver

import io.reactivex.CompletableObserver; //导入依赖的package包/类
protected CompletableObserver failOrCountDownCompletableObserver(CountDownLatch latch) {
    return new CompletableObserver() {

        @Override
        public void onSubscribe(Disposable d) {

        }

        @Override
        public void onComplete() {
            latch.countDown();
        }

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

    };
}
 
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:21,代码来源:RXVertxDaoTestBase.java

示例9: toCompletableObserver

import io.reactivex.CompletableObserver; //导入依赖的package包/类
/**
 * Performs the opposite translation from
 * {@link MaybeConsumers#fromCompletableObserver(CompletableObserver)}
 */
public static CompletableObserver toCompletableObserver(final MaybeConsumer<Success> c) {
    return new CompletableObserver() {
        @Override
        public void onSubscribe(@NonNull Disposable d) {
            // do nothing
        }

        @Override
        public void onComplete() {
            c.success(Success.SUCCESS);
        }

        @Override
        public void onError(@NonNull Throwable e) {
            c.fail(throwableToException(e));
        }
    };
}
 
开发者ID:google,项目名称:science-journal,代码行数:23,代码来源:MaybeConsumers.java

示例10: observe

import io.reactivex.CompletableObserver; //导入依赖的package包/类
public static CompletableObserver observe(String tag, String operation) {
    return new CompletableObserver() {
        @Override
        public void onSubscribe(Disposable d) {

        }

        @Override
        public void onComplete() {

        }

        @Override
        public void onError(Throwable e) {
            complain(e, tag, operation);
        }
    };
}
 
开发者ID:google,项目名称:science-journal,代码行数:19,代码来源:LoggingConsumer.java

示例11: decks_renamed

import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Test
public void decks_renamed() {
    List<Deck> renamedData = mUser.save().andThen((final CompletableObserver cs) -> {
        Deck deck = new Deck(mUser);
        deck.setName("ToRename");
        deck.setAccepted(true);
        deck.create().subscribe(cs);
    }).andThen((ObservableSource<List<Deck>>) observer ->
            mUser.fetchChildren(mUser.getChildReference(Deck.class), Deck.class)
                    .subscribe(observer)
    ).firstOrError().flatMapCompletable(data -> {
        assertTrue(data.size() == 1 && data.get(0).getName().equals("ToRename"));
        Deck fetchedDeck = data.get(0);
        fetchedDeck.setName("Renamed");
        return fetchedDeck.save();
    }).andThen((ObservableSource<List<Deck>>) observer ->
            mUser.fetchChildren(mUser.getChildReference(Deck.class), Deck.class)
                    .subscribe(observer)
    ).firstOrError().blockingGet();
    assertTrue(renamedData.size() == 1 && renamedData.get(0).getName()
            .equals("Renamed"));
}
 
开发者ID:dasfoo,项目名称:delern,代码行数:23,代码来源:DeckTest.java

示例12: decks_changedDeckType

import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Test
public void decks_changedDeckType() {
    List<Deck> deckTypeData = mUser.save().andThen((final CompletableObserver cs) -> {
        Deck deck = new Deck(mUser);
        deck.setName("DeckType");
        deck.setAccepted(true);
        deck.create().subscribe(cs);
    }).andThen((ObservableSource<List<Deck>>) observer ->
            mUser.fetchChildren(mUser.getChildReference(Deck.class), Deck.class)
                    .subscribe(observer)
    ).firstOrError().flatMapCompletable(data -> {
        assertTrue(data.size() == 1 && data.get(0).getName().equals("DeckType"));
        Deck fetchedDeck = data.get(0);
        fetchedDeck.setDeckType(DeckType.SWISS.name());
        return fetchedDeck.save();
    }).andThen((ObservableSource<List<Deck>>) observer ->
            mUser.fetchChildren(mUser.getChildReference(Deck.class), Deck.class)
                    .subscribe(observer)
    ).firstOrError().blockingGet();
    assertTrue(deckTypeData.size() == 1 && deckTypeData.get(0).getDeckType()
            .equals(DeckType.SWISS.name()));
}
 
开发者ID:dasfoo,项目名称:delern,代码行数:23,代码来源:DeckTest.java

示例13: decks_createdAndDeleted

import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Test
public void decks_createdAndDeleted() throws Exception {
    List<Deck> deletedDeck = mUser.save().andThen((final CompletableObserver cs) -> {
        Deck deck = new Deck(mUser);
        deck.setName("Created");
        deck.setAccepted(true);
        deck.create().subscribe(cs);
    }).andThen((ObservableSource<List<Deck>>) observer ->
            mUser.fetchChildren(mUser.getChildReference(Deck.class), Deck.class)
                    .subscribe(observer)
    ).firstOrError().flatMapCompletable(data -> {
        assertTrue(data.size() == 1 && data.get(0).getName().equals("Created"));
        return data.get(0).delete();
    }).andThen((ObservableSource<List<Deck>>) observer ->
            mUser.fetchChildren(mUser.getChildReference(Deck.class), Deck.class)
                    .subscribe(observer)
    ).firstOrError().blockingGet();
    assertTrue(deletedDeck.size() == 0);
}
 
开发者ID:dasfoo,项目名称:delern,代码行数:20,代码来源:DeckTest.java

示例14: cards_createdAndFetched

import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Test
public void cards_createdAndFetched() throws Exception {
    final Deck deck = new Deck(mUser);
    List<Card> cards = mUser.save().andThen((final CompletableObserver cs) -> {
        deck.setName("CreateCards");
        deck.setAccepted(true);
        deck.create().subscribe(cs);
    }).andThen((ObservableSource<List<Deck>>) observer ->
            mUser.fetchChildren(mUser.getChildReference(Deck.class), Deck.class)
                    .subscribe(observer)
    ).firstOrError().flatMapCompletable(data -> {
        assertTrue(data.size() == 1 && data.get(0).getName().equals("CreateCards"));
        Card newCard = new Card(data.get(0));
        newCard.setFront("frontSide");
        newCard.setBack("backSide");
        return newCard.create();
    }).andThen((ObservableSource<List<Card>>) observer ->
            deck.fetchChildren(deck.getChildReference(Card.class), Card.class)
                    .subscribe(observer)
    ).firstOrError().blockingGet();
    assertTrue(cards.size() == 1 && cards.get(0).getFront().equals("frontSide") &&
            cards.get(0).getBack().equals("backSide"));
}
 
开发者ID:dasfoo,项目名称:delern,代码行数:24,代码来源:CardTest.java

示例15: failOrCountDownCompletableObserver

import io.reactivex.CompletableObserver; //导入依赖的package包/类
protected  CompletableObserver failOrCountDownCompletableObserver(CountDownLatch latch) {
    return new CompletableObserver() {

        @Override
        public void onSubscribe(Disposable d) {

        }

        @Override
        public void onComplete() {
            latch.countDown();
        }

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

    };
}
 
开发者ID:jklingsporn,项目名称:vertx-jooq,代码行数:21,代码来源:RXVertxDaoTestBase.java


注:本文中的io.reactivex.CompletableObserver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。