Java Code Examples for io.reactivex.Observable.empty()

The following are Jave code examples for showing how to use empty() of the io.reactivex.Observable class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: vt-support   File: StorageImpl.java   View Source Code Vote up 7 votes
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();
  }
}
 
Example 2
Project: Auto.js   File: VersionService.java   View Source Code Vote up 6 votes
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;
}
 
Example 3
Project: buckaroo   File: MoreObservablesTest.java   View Source Code Vote up 6 votes
@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);
}
 
Example 4
Project: XPermission   File: XPermission.java   View Source Code Vote up 5 votes
private Observable<?> pending(final String... permissions) {
    for (String p : permissions) {
        if (!XPermissionActivity.containsByPermission(p)) {
            return Observable.empty();
        }
    }
    return Observable.just(TRIGGER);
}
 
Example 5
Project: RxDiffUtil   File: DiffRequestManager.java   View Source Code Vote up 5 votes
/**
 * @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);
}
 
Example 6
Project: AesExoPlayer   File: RxPermissions.java   View Source Code Vote up 5 votes
private Observable<?> pending(final String... permissions) {
    for (String p : permissions) {
        if (!mRxPermissionsFragment.containsByPermission(p)) {
            return Observable.empty();
        }
    }
    return Observable.just(new Object());
}
 
Example 7
Project: CacheBank   File: CacheObject.java   View Source Code Vote up 5 votes
protected Observable getValueObservable(){
    if(valueObservable == null){
        if(value == null){
            return Observable.empty();
        }
        return Observable.just(value);
    }
    return valueObservable;
}
 
Example 8
Project: XSnow   File: RxPermissions.java   View Source Code Vote up 5 votes
private Observable<?> pending(final String... permissions) {
    for (String p : permissions) {
        if (!mRxPermissionsFragment.containsByPermission(p)) {
            return Observable.empty();
        }
    }
    return Observable.just(new Object());
}
 
Example 9
Project: RxSWT   File: TestObserverUtil.java   View Source Code Vote up 5 votes
@SuppressWarnings({ "unchecked", "rawtypes" })
public static TestObserver<?> getEmptySubscribedTestObserver() {
	Observable<?> empty = Observable.empty();
	TestObserver<?> testObserver = TestObserver.create();
	empty.subscribe((Observer) testObserver);
	return testObserver;
}
 
Example 10
Project: KTools   File: RxPermissions.java   View Source Code Vote up 5 votes
private Observable<?> pending(final String... permissions) {
    for (String p : permissions) {
        if (!mRxPermissionsFragment.containsByPermission(p)) {
            return Observable.empty();
        }
    }
    return Observable.just(new Object());
}
 
Example 11
Project: RxRedux   File: UserListActivity.java   View Source Code Vote up 5 votes
@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();
    }
}
 
Example 12
Project: mvvm-template   File: TimelineModel.java   View Source Code Vote up 5 votes
@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();
}
 
Example 13
Project: RxPermission   File: RealRxPermission.java   View Source Code Vote up 5 votes
@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);
}
 
Example 14
Project: buckaroo   File: InstallExistingTasks.java   View Source Code Vote up 5 votes
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));
    }
 
Example 15
Project: Learning-RxJava   File: Ch2_20.java   View Source Code Vote up 4 votes
public static void main(String[] args) {
    Observable<String> empty = Observable.empty();
    empty.subscribe(System.out::println,
            Throwable::printStackTrace,
            () -> System.out.println("Done!"));
}
 
Example 16
Project: GitHub   File: UseCaseTest.java   View Source Code Vote up 4 votes
@Override Observable<Object> buildUseCaseObservable(Params params) {
  return Observable.empty();
}
 
Example 17
Project: RxJava2-Android-Sample   File: EmptyNeverThrowExampleActivity.java   View Source Code Vote up 4 votes
private Observable<String> getEmptyObservable() {
    return Observable.empty();
}
 
Example 18
Project: github-users   File: Trigger.java   View Source Code Vote up 4 votes
public static <T> Observable<T> noTriggers() {
  return Observable.empty();
}
 
Example 19
Project: clean-news   File: UseCaseTest.java   View Source Code Vote up 4 votes
@Override
public Observable<Object> buildUseCaseObservable(Params params) {
    return Observable.empty();
}
 
Example 20
Project: Subs   File: UseCaseTest.java   View Source Code Vote up 4 votes
@Override public Observable<Object> buildUseCaseObservable(Params params) {
    return Observable.empty();
}