本文整理汇总了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();
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
示例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);
}
示例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));
}
示例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!"));
}
示例14: buildUseCaseObservable
import io.reactivex.Observable; //导入方法依赖的package包/类
@Override Observable<Object> buildUseCaseObservable(Params params) {
return Observable.empty();
}
示例15: getEmptyObservable
import io.reactivex.Observable; //导入方法依赖的package包/类
private Observable<String> getEmptyObservable() {
return Observable.empty();
}