rx.Observable.doAfterTerminate()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中rx.Observable.doAfterTerminate()方法的一些代码示例,展示了Observable.doAfterTerminate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.doAfterTerminate()方法的具体详情如下:
包路径:rx.Observable
类名称:Observable
方法名:doAfterTerminate

Observable.doAfterTerminate介绍

暂无

代码示例

代码示例来源:origin: PipelineAI/pipeline

  1. }).doAfterTerminate(new Action0() {

代码示例来源:origin: PipelineAI/pipeline

  1. }).doAfterTerminate(new Action0() {

代码示例来源:origin: PipelineAI/pipeline

  1. }).doAfterTerminate(new Action0() {

代码示例来源:origin: rchodava/datamill

  1. @Override
  2. public Observable<byte[]> asChunks() {
  3. return StringObservable.from(inputStream)
  4. .doAfterTerminate(completionHandler != null ? completionHandler : () -> {});
  5. }

代码示例来源:origin: akarnokd/RxAgera

  1. public RxObservableAsAgera(rx.Observable<?> source) {
  2. if (source instanceof Subject) {
  3. // no need to publish/autoConnect a subject
  4. this.source = source.doAfterTerminate(this);
  5. } else {
  6. this.source = source.doAfterTerminate(this).publish().autoConnect();
  7. }
  8. this.updatables = new HashMap<>();
  9. }

代码示例来源:origin: io.vertx/vertx-rx-java

  1. /**
  2. * Generates a {@link Observable} from {@link SQLConnection} operations.
  3. *
  4. * @param client the {@link SQLClient}
  5. * @param sourceSupplier a user-provided function returning a {@link Observable} generated by interacting with the given {@link SQLConnection}
  6. * @param <T> the type of the items emitted by the {@link Observable}
  7. * @return an {@link Observable} generated from {@link SQLConnection} operations
  8. */
  9. public static <T> Observable<T> usingConnectionObservable(SQLClient client, Function<SQLConnection, Observable<T>> sourceSupplier) {
  10. return client.rxGetConnection().flatMapObservable(conn -> {
  11. return sourceSupplier.apply(conn).doAfterTerminate(conn::close);
  12. });
  13. }

代码示例来源:origin: vert-x3/vertx-rx

  1. /**
  2. * Generates a {@link Observable} from {@link SQLConnection} operations.
  3. *
  4. * @param client the {@link SQLClient}
  5. * @param sourceSupplier a user-provided function returning a {@link Observable} generated by interacting with the given {@link SQLConnection}
  6. * @param <T> the type of the items emitted by the {@link Observable}
  7. * @return an {@link Observable} generated from {@link SQLConnection} operations
  8. */
  9. public static <T> Observable<T> usingConnectionObservable(SQLClient client, Function<SQLConnection, Observable<T>> sourceSupplier) {
  10. return client.rxGetConnection().flatMapObservable(conn -> {
  11. return sourceSupplier.apply(conn).doAfterTerminate(conn::close);
  12. });
  13. }

代码示例来源:origin: ArturVasilov/AndroidSchool

  1. @Test
  2. public void testTask2() throws Exception {
  3. final Observable<BigInteger> observable = RxJavaTask6.task6Observable();
  4. final long firstStart = System.nanoTime();
  5. observable
  6. .doAfterTerminate(() -> {
  7. final long firstTime = System.nanoTime() - firstStart;
  8. final long secondStart = System.nanoTime();
  9. observable.subscribe(bigInteger -> {
  10. final long secondTime = System.nanoTime() - secondStart;
  11. assertTrue("Second request to observable is too slow, probably you haven't cached it",
  12. secondTime < firstTime / 2);
  13. });
  14. })
  15. .subscribe(value -> {
  16. assertEquals(EXPECTED_RESULT, value);
  17. }, throwable -> fail());
  18. }

代码示例来源:origin: nurkiewicz/rxjava-book-examples

  1. @Test
  2. public void sample_189() throws Exception {
  3. Connection connection = null;
  4. PreparedStatement statement =
  5. connection.prepareStatement("SELECT ...");
  6. statement.setFetchSize(1000);
  7. ResultSet rs = statement.executeQuery();
  8. Observable<Object[]> result =
  9. Observable
  10. .from(ResultSetIterator.iterable(rs))
  11. .doAfterTerminate(() -> {
  12. try {
  13. rs.close();
  14. statement.close();
  15. connection.close();
  16. } catch (SQLException e) {
  17. log.warn("Unable to close", e);
  18. }
  19. });
  20. }

代码示例来源:origin: ArturVasilov/AndroidSchool

  1. private void load(boolean restart) {
  2. Observable.Transformer<List<Movie>, List<Movie>> lifecycleTransformer =
  3. restart
  4. ? mLifecycleHandler.reload(R.id.movies_loader_request)
  5. : mLifecycleHandler.load(R.id.movies_loader_request);
  6. RepositoryProvider.getRepository().loadMovies(mType)
  7. .doOnSubscribe(() -> setRefreshing(true))
  8. .doAfterTerminate(() -> setRefreshing(false))
  9. .compose(lifecycleTransformer)
  10. .subscribe(this::handleMovies, this::handleError);
  11. }

代码示例来源:origin: w0080626/GankIO

  1. @Override
  2. public void onRefresh() {
  3. setCurPage(1);
  4. ListModel.getInstance().getResult(title, 20, getCurPage()).doAfterTerminate(new Action0() {
  5. @Override
  6. public void call() {
  7. setCurPage(2);
  8. }
  9. }).unsafeSubscribe(getRefreshSubscriber());
  10. }

代码示例来源:origin: vert-x3/vertx-rx

  1. protected void assertTableContainsInitDataOnly() throws Exception {
  2. client.rxGetConnection().flatMapObservable(conn -> {
  3. return uniqueNames(conn).doAfterTerminate(conn::close);
  4. }).test()
  5. .awaitTerminalEvent()
  6. .assertCompleted()
  7. .assertValues(NAMES.stream().sorted().distinct().toArray(String[]::new));
  8. }

代码示例来源:origin: hawkular/hawkular-metrics

  1. .flatMap(mId -> metricsService.findMetric(mId)
  2. .doOnNext(m -> count.incrementAndGet())
  3. .doAfterTerminate(() ->
  4. logger.infof("Fetched %d metric definitions for tenant %s", count.get(),
  5. tenantId))),

代码示例来源:origin: org.hawkular.metrics/hawkular-metrics-core-service

  1. .flatMap(mId -> metricsService.findMetric(mId)
  2. .doOnNext(m -> count.incrementAndGet())
  3. .doAfterTerminate(() ->
  4. logger.infof("Fetched %d metric definitions for tenant %s", count.get(),
  5. tenantId))),

代码示例来源:origin: georocket/georocket

  1. .doAfterTerminate(chunk::close)

代码示例来源:origin: rchodava/datamill

  1. .doAfterTerminate(() -> {
  2. if (first[0]) {
  3. sendFullResponse(context, originalRequest,

代码示例来源:origin: vert-x3/vertx-rx

  1. private Observable<String> inTransaction(Exception e) throws Exception {
  2. return client.rxGetConnection().flatMapObservable(conn -> {
  3. return rxInsertExtraFolks(conn)
  4. .andThen(uniqueNames(conn))
  5. .compose(upstream -> e == null ? upstream : upstream.concatWith(Observable.error(e)))
  6. .compose(SQLClientHelper.txObservableTransformer(conn))
  7. .concatWith(rxAssertAutoCommit(conn).toObservable())
  8. .doAfterTerminate(conn::close);
  9. });
  10. }
  11. }

相关文章

Observable类方法