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


Java Observable.empty方法代码示例

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


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

示例1: get

import io.reactivex.Observable; //导入方法依赖的package包/类
private Observable<Entry> get(SelectBuilder builder) {
  if (isError) {
    return Observable.empty();
  } else {
    return builder.get(new ResultSetMapper<Entry>() {
      @Override
      public Entry apply(@Nonnull ResultSet rs) throws SQLException {
        byte[] uncompressed;
        try {
          final byte[] compressedTileData = rs.getBytes("tile_data");
          uncompressed = CompressUtil.getUncompressedFromGzip(compressedTileData);
        } catch (final IOException ex) {
          throw Exceptions.propagate(ex);
        }
        return new Entry(rs.getInt("zoom_level"), rs.getInt("tile_column"),
            flipY(rs.getInt("tile_row"), rs.getInt("zoom_level")), uncompressed);
      }
    }).toObservable();
  }
}
 
开发者ID:OrdnanceSurvey,项目名称:vt-support,代码行数:21,代码来源:StorageImpl.java

示例2: checkUpdateIfUsingWifi

import io.reactivex.Observable; //导入方法依赖的package包/类
private Observable<VersionInfo> checkUpdateIfUsingWifi(Context context) {
    if (!NetworkUtils.isWifiAvailable(context)) {
        return Observable.empty();
    }
    Observable<VersionInfo> observable = checkForUpdates();
    observable.subscribe(new SimpleObserver<VersionInfo>() {
        @Override
        public void onNext(@NonNull VersionInfo versionInfo) {
            if (versionInfo.isValid()) {
                setVersionInfo(versionInfo);
            }
        }

        @Override
        public void onError(@NonNull Throwable e) {
            e.printStackTrace();
        }
    });
    return observable;
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:21,代码来源:VersionService.java

示例3: shouldHandleEmptyInMergedMaps

import io.reactivex.Observable; //导入方法依赖的package包/类
@Test
public void shouldHandleEmptyInMergedMaps() throws Exception {

    final Observable<Integer> a = Observable.empty();

    final Observable<Integer> b = Observable.create(s -> {
        s.onNext(1);
        s.onNext(2);
        s.onNext(3);
        s.onComplete();
    });

    final ImmutableMap<String, Observable<Integer>> map = ImmutableMap.of(
        "a", a,
        "b", b
    );

    final Observable<ImmutableMap<String, Integer>> observableMap =
        MoreObservables.mergeMaps(map);

    final int error = observableMap
        .reduce(1, (x, y) -> 0)
        .blockingGet();

    assertEquals(0, error);
}
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:27,代码来源:MoreObservablesTest.java

示例4: pending

import io.reactivex.Observable; //导入方法依赖的package包/类
private Observable<?> pending(final String... permissions) {
    for (String p : permissions) {
        if (!XPermissionActivity.containsByPermission(p)) {
            return Observable.empty();
        }
    }
    return Observable.just(TRIGGER);
}
 
开发者ID:paozhuanyinyu,项目名称:XPermission,代码行数:9,代码来源:XPermission.java

示例5: diffResults

import io.reactivex.Observable; //导入方法依赖的package包/类
/**
 * @return The {@link Observable} you can subscribe to to receive the {@link RxDiffResult}.
 */
@NonNull
public Observable<RxDiffResult> diffResults() {
    Observable<RxDiffResult> cachedResult;
    if (mCachedResultForSubscription != null) {
        final RxDiffResult rxDiffResult = mCachedResultForSubscription;
        cachedResult = Observable.just(rxDiffResult);
        mCachedResultForSubscription = null;
    } else {
        cachedResult = Observable.empty();
    }
    return mRelay.hide()
            .startWith(cachedResult);
}
 
开发者ID:storix,项目名称:RxDiffUtil,代码行数:17,代码来源:DiffRequestManager.java

示例6: pending

import io.reactivex.Observable; //导入方法依赖的package包/类
private Observable<?> pending(final String... permissions) {
    for (String p : permissions) {
        if (!mRxPermissionsFragment.containsByPermission(p)) {
            return Observable.empty();
        }
    }
    return Observable.just(new Object());
}
 
开发者ID:ChangWeiBa,项目名称:AesExoPlayer,代码行数:9,代码来源:RxPermissions.java

示例7: getValueObservable

import io.reactivex.Observable; //导入方法依赖的package包/类
protected Observable getValueObservable(){
    if(valueObservable == null){
        if(value == null){
            return Observable.empty();
        }
        return Observable.just(value);
    }
    return valueObservable;
}
 
开发者ID:JSpiner,项目名称:CacheBank,代码行数:10,代码来源:CacheObject.java

示例8: getEmptySubscribedTestObserver

import io.reactivex.Observable; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public static TestObserver<?> getEmptySubscribedTestObserver() {
	Observable<?> empty = Observable.empty();
	TestObserver<?> testObserver = TestObserver.create();
	empty.subscribe((Observer) testObserver);
	return testObserver;
}
 
开发者ID:SimonScholz,项目名称:RxSWT,代码行数:8,代码来源:TestObserverUtil.java

示例9: initialize

import io.reactivex.Observable; //导入方法依赖的package包/类
@Override
public void initialize() {
    eventObservable = Observable.empty();
    viewModel = ViewModelProviders.of(this,
            new ViewModelFactory(DataServiceFactory.getInstance())).get(UserListVM.class);
    if (viewState == null) {
        eventObservable = Single.<BaseEvent>just(new GetPaginatedUsersEvent(0))
                .doOnSuccess(event -> Log.d("GetPaginatedUsersEvent", FIRED)).toObservable();
    }
}
 
开发者ID:Zeyad-37,项目名称:RxRedux,代码行数:11,代码来源:UserListActivity.java

示例10: construct

import io.reactivex.Observable; //导入方法依赖的package包/类
@NonNull
public static Observable<List<TimelineModel>> construct(@Nullable List<Comment> comments) {
    if (comments == null || comments.isEmpty()) return Observable.empty();
    return Observable.fromIterable(comments)
            .map(TimelineModel::new)
            .toList()
            .toObservable();
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:9,代码来源:TimelineModel.java

示例11: pending

import io.reactivex.Observable; //导入方法依赖的package包/类
@NonNull @CheckReturnValue private Observable<?> pending(@NonNull final String... permissions) {
  for (final String p : permissions) {
    if (!currentPermissionRequests.containsKey(p)) {
      return Observable.empty();
    }
  }

  return Observable.just(TRIGGER);
}
 
开发者ID:vanniktech,项目名称:RxPermission,代码行数:10,代码来源:RealRxPermission.java

示例12: downloadResolvedDependency

import io.reactivex.Observable; //导入方法依赖的package包/类
private static Observable<Event> downloadResolvedDependency(final FileSystem fs, final ResolvedDependency resolvedDependency, final Path target) {

        Preconditions.checkNotNull(fs);
        Preconditions.checkNotNull(resolvedDependency);
        Preconditions.checkNotNull(target);

        final Observable<Event> downloadSourceCode = Single.fromCallable(() -> Files.exists(target))
            .flatMapObservable(exists -> {
                if (exists) {
                    return Observable.empty();
                }
                return resolvedDependency.source.join(
                    gitCommit -> CacheTasks.cloneAndCheckoutUsingCache(gitCommit, target),
                    remoteArchive -> CacheTasks.downloadUsingCache(remoteArchive, target, StandardCopyOption.REPLACE_EXISTING));
            });

        final Path buckFilePath = fs.getPath(target.toString(), "BUCK");
        final Observable<Event> downloadBuckFile = Files.exists(buckFilePath) ?
            Observable.empty() :
            resolvedDependency.buckResource
                .map(x -> CommonTasks.downloadRemoteFile(fs, x, buckFilePath))
                .orElse(Observable.empty());

        final Path buckarooDepsFilePath = fs.getPath(target.toString(), "BUCKAROO_DEPS");
        final Observable<Event> writeBuckarooDeps = Single.fromCallable(() ->
            CommonTasks.generateBuckarooDeps(resolvedDependency.dependencies))
            .flatMap(content -> CommonTasks.writeFile(
                content,
                buckarooDepsFilePath,
                true))
            .cast(Event.class)
            .toObservable();

        return Observable.concat(
            downloadSourceCode,
            downloadBuckFile,
            writeBuckarooDeps.cast(Event.class));
    }
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:39,代码来源:InstallExistingTasks.java

示例13: main

import io.reactivex.Observable; //导入方法依赖的package包/类
public static void main(String[] args) {
    Observable<String> empty = Observable.empty();
    empty.subscribe(System.out::println,
            Throwable::printStackTrace,
            () -> System.out.println("Done!"));
}
 
开发者ID:PacktPublishing,项目名称:Learning-RxJava,代码行数:7,代码来源:Ch2_20.java

示例14: buildUseCaseObservable

import io.reactivex.Observable; //导入方法依赖的package包/类
@Override Observable<Object> buildUseCaseObservable(Params params) {
  return Observable.empty();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:UseCaseTest.java

示例15: getEmptyObservable

import io.reactivex.Observable; //导入方法依赖的package包/类
private Observable<String> getEmptyObservable() {
    return Observable.empty();
}
 
开发者ID:changjiashuai,项目名称:RxJava2-Android-Sample,代码行数:4,代码来源:EmptyNeverThrowExampleActivity.java


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