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


Java RxJavaInterop类代码示例

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


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

示例1: handle

import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@Override
public void handle(RoutingContext routingContext) {
  Long albumId = PathUtil.parseLongParam(routingContext.pathParam("albumId"));
  if (albumId == null) {
    routingContext.next();
    return;
  }

  com.couchbase.client.java.document.json.JsonArray params = com.couchbase.client.java.document.json.JsonArray.from(albumId);
  ParametrizedQuery parametrizedQuery = Query.parametrized(findRecentCommentsByAlbum, params);
  Observable<AsyncQueryRow> rowsObservable = albumCommentsBucket.query(parametrizedQuery)
    .flatMap(AsyncQueryResult::rows);
  RxJavaInterop.toV2Flowable(rowsObservable)
    .observeOn(RxHelper.scheduler(routingContext.vertx().getOrCreateContext()))
    .limit(5)
    .collect(JsonArray::new, (jsonArray, row) -> jsonArray.add(new JsonObject(row.value().toMap())))
    .flatMap(data -> {
      routingContext.put("comments", data);
      return templateEngine.rxRender(routingContext, "templates/partials/album_comments");
    }).subscribe(routingContext.response()::end, routingContext::fail);
}
 
开发者ID:tsegismont,项目名称:vertx-musicstore,代码行数:22,代码来源:AjaxAlbumCommentsHandler.java

示例2: decodeQrCode

import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
private void decodeQrCode() {
    if (mBigImageView.getCurrentImageFile() == null) {
        return;
    }
    disposeQrCodeDecode();
    mQrCodeDecode = RxJavaInterop
            .toV2Observable(RxQrCode.scanFromPicture(
                    mBigImageView.getCurrentImageFile().getAbsolutePath()))
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<Result>() {
                @Override
                public void accept(Result result) throws Exception {
                    Toast.makeText(LongImageActivity.this,
                            "Found " + result.getText(),
                            Toast.LENGTH_SHORT).show();
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    Toast.makeText(LongImageActivity.this,
                            "Not found",
                            Toast.LENGTH_SHORT).show();
                }
            });
}
 
开发者ID:Piasy,项目名称:BigImageViewer,代码行数:27,代码来源:LongImageActivity.java

示例3: handle

import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@Override
public void handle(RoutingContext rc) {
  Long albumId = PathUtil.parseLongParam(rc.pathParam("albumId"));
  if (albumId == null) {
    rc.next();
    return;
  }

  User user = rc.user();
  if (user == null) {
    rc.response().setStatusCode(HTTP_UNAUTHORIZED).end();
    return;
  }

  String comment = rc.getBodyAsString();
  if (comment == null || comment.isEmpty()) {
    rc.response().setStatusCode(HTTP_BAD_REQUEST).end();
    return;
  }

  long timestamp = System.currentTimeMillis();

  JsonObject content = new JsonObject()
    .put("albumId", albumId)
    .put("username", user.principal().getValue("username"))
    .put("timestamp", timestamp)
    .put("comment", comment);

  JsonDocument document = JsonDocument.create("comment::" + timestamp, com.couchbase.client.java.document.json.JsonObject.from(content.getMap()));
  Vertx vertx = rc.vertx();
  Observable<JsonDocument> documentObservable = albumCommentsBucket.upsert(document);
  RxJavaInterop.toV2Single(documentObservable.toSingle())
    .observeOn(RxHelper.scheduler(vertx.getOrCreateContext()))
    .doOnSuccess(doc -> vertx.setTimer(1000, v -> {
      String address = "album." + albumId + ".comments.new";
      vertx.eventBus().<JsonObject>publish(address, content);
    }))
    .subscribe(doc -> rc.response().end(), rc::fail);
}
 
开发者ID:tsegismont,项目名称:vertx-musicstore,代码行数:40,代码来源:AddAlbumCommentHandler.java

示例4: setupBucket

import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
private Completable setupBucket() {
  SimpleQuery findPrimaryIndex = Query.simple(couchbaseQueries.getProperty("findAlbumCommentsPrimaryIndex"));
  SimpleQuery createPrimaryIndex = Query.simple(couchbaseQueries.getProperty("createAlbumCommentsPrimaryIndex"));
  rx.Completable setupCompletable = albumCommentsBucket.get().query(findPrimaryIndex)
    .switchIfEmpty(albumCommentsBucket.get().query(createPrimaryIndex))
    .toCompletable();
  return RxJavaInterop.toV2Completable(setupCompletable)
    .observeOn(RxHelper.scheduler(vertx.getOrCreateContext()));
}
 
开发者ID:tsegismont,项目名称:vertx-musicstore,代码行数:10,代码来源:MusicStoreVerticle.java

示例5: selectAllAsNotifiedObservable

import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
public <T> Observable<List<T>> selectAllAsNotifiedObservable(BaseEntity<T> entity,
                                                             String order) {
    String sql = createSelectAllQuery(entity, order);

    return RxJavaInterop.toV2Observable(
            briteDatabase.createQuery(entity.getTableName(), sql)
                    .mapToList(entity::fromCursor));
}
 
开发者ID:andreybgm,项目名称:gigreminder,代码行数:9,代码来源:BriteDatabaseHelper.java

示例6: forFlowable

import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@Override public <U> FlowableTransformer<U, U> forFlowable() {
  return new FlowableTransformer<U, U>() {
    @Override public Publisher<U> apply(Flowable<U> source) {
      rx.Observable<U> rxObservable = RxJavaInterop.toV1Observable(source.toObservable(), strategy);
      rx.Observable<T> observableBound = rxObservable.compose(
          (rx.Observable.Transformer<? super U, ? extends T>) rxTransformerBound);
      return (Publisher<U>) RxJavaInterop.toV2Observable(observableBound).toFlowable(strategy);
    }
  };
}
 
开发者ID:VictorAlbertos,项目名称:RxLifecycleInterop,代码行数:11,代码来源:LifecycleTransformer2xBehaviour.java

示例7: forSingle

import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@Override public <U> SingleTransformer<U, U> forSingle() {
  return new SingleTransformer<U, U>() {
    @Override public SingleSource<U> apply(io.reactivex.Single<U> source) {
      rx.Single<U> rxSourceSingle =
          RxJavaInterop.toV1Single(source);

      rx.Single<T> rxBoundSingle = rxSourceSingle
          .compose((Single.Transformer<? super U, ? extends T>) rxSingleTransformer);

      return (io.reactivex.Single<U>) RxJavaInterop.toV2Single(rxBoundSingle);
    }
  };
}
 
开发者ID:VictorAlbertos,项目名称:RxLifecycleInterop,代码行数:14,代码来源:LifecycleTransformer2xBehaviour.java

示例8: bindActivity

import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@NonNull
@CheckResult
public static <T> LifecycleTransformer2x<T> bindActivity(
    @NonNull final Observable<ActivityEvent> lifecycle,
    @NonNull final BackpressureStrategy strategy) {
  LifecycleTransformer<T> rxTransformer =
      RxLifecycleAndroid.bindActivity(RxJavaInterop.toV1Observable(lifecycle, strategy));
  return new LifecycleTransformer2xBehaviour<>(rxTransformer, rxTransformer.forSingle(),
      strategy);
}
 
开发者ID:VictorAlbertos,项目名称:RxLifecycleInterop,代码行数:11,代码来源:Rx2LifecycleAndroid.java

示例9: bindFragment

import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@NonNull
@CheckResult
public static <T> LifecycleTransformer2x<T> bindFragment(
    @NonNull final Observable<FragmentEvent> lifecycle,
    @NonNull final BackpressureStrategy strategy) {
  LifecycleTransformer<T> rxTransformer =
      RxLifecycleAndroid.bindFragment(RxJavaInterop.toV1Observable(lifecycle, strategy));
  return new LifecycleTransformer2xBehaviour<>(rxTransformer, rxTransformer.forSingle(),
      strategy);
}
 
开发者ID:VictorAlbertos,项目名称:RxLifecycleInterop,代码行数:11,代码来源:Rx2LifecycleAndroid.java

示例10: bindPreference

import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
void bindPreference(final CheckBox checkBox, Preference<Boolean> preference) {
  // Bind the preference to the checkbox.
  disposables.add(preference.asObservable()
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(checkBox::setChecked));
  // Bind the checkbox to the preference.
  disposables.add(RxJavaInterop.toV2Observable(RxCompoundButton.checkedChanges(checkBox))
      .skip(1) // First emission is the original state.
      .subscribe(preference.asConsumer()));
}
 
开发者ID:f2prateek,项目名称:rx-preferences,代码行数:11,代码来源:SampleActivity.java

示例11: singleAsObservable

import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
public Observable<E> singleAsObservable() {
    rx.Observable<E> o = briteResolver.createQuery(baseUri,
            projection,
            selection.toString(),
            getSelectionArgs(),
            sortOrderWithLimit(" LIMIT 1 "), true)
            .mapToOne(cursor -> EntityMapper.forEntity(clazz).fromCursor(cursor))
            .throttleFirst(THROTTLE_BATCH, TimeUnit.MILLISECONDS);

    return RxJavaInterop.toV2Observable(o);
}
 
开发者ID:oVirt,项目名称:moVirt,代码行数:12,代码来源:ProviderFacade.java

示例12: onStartClicks

import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@Override
public Observable<Object> onStartClicks() {
    return RxJavaInterop.toV2Observable(RxView.clicks(btnStart).map(aVoid -> new Object()));
}
 
开发者ID:mkoslacz,项目名称:Moviper,代码行数:5,代码来源:MainActivity.java

示例13: onStopClicks

import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@Override
public Observable<Object> onStopClicks() {
    return RxJavaInterop.toV2Observable(RxView.clicks(btnStop).map(aVoid -> new Object()));
}
 
开发者ID:mkoslacz,项目名称:Moviper,代码行数:5,代码来源:MainActivity.java

示例14: startAsV1Observable

import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@Deprecated
public rx.Observable<Integer> startAsV1Observable() {
    return RxJavaInterop.toV1Observable(start());
}
 
开发者ID:Piasy,项目名称:RxComboDetector,代码行数:5,代码来源:RxComboDetector.java

示例15: phoneNumberChanges

import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@Override
public Flowable<CharSequence> phoneNumberChanges() {
    return RxJavaInterop.toV2Flowable(RxTextView.textChanges(mEtPhone));
}
 
开发者ID:Piasy,项目名称:YaMvp,代码行数:5,代码来源:MainFragment.java


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