APISonar


io.reactivex.schedulers.Schedulers.io

> io > reactivex > schedulers > Schedulers > io
io APIs reactivex APIs schedulers APIs Schedulers APIs io APIs

Example 1
private void doSomeWork() {
        getObservable()
                .switchMap(new Function<Integer, ObservableSource<String>>() {
                    @Override
                    public ObservableSource<String> apply(Integer integer) {
                        int delay = new Random().nextInt(2);

                        return Observable.just(integer.toString() + "x")
                                .delay(delay, TimeUnit.SECONDS, Schedulers.io());
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(getObserver());
    }
Example 2
public Observable<Response> loadPages(Integer... pages) {
    return Observable.fromArray(pages)
        .flatMap(page -> Observable.fromCallable(() -> downloadImage(page)))
        .subscribeOn(Schedulers.io());
  }
Example 3
public Observable<Long> addTagObservable(final String title) {
    return Observable.fromCallable(() -> {
      long result = bookmarksDBAdapter.addTag(title);
      tagPublishSubject.onNext(new Tag(result, title));
      return result;
    }).subscribeOn(Schedulers.io());
  }
Example 4
public void startLongOperation() {

    _progress.setVisibility(View.VISIBLE);
    _log("Button Clicked");

    DisposableObserver<Boolean> d = _getDisposableObserver();

    _getObservable()
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(d);

    _disposables.add(d);
  }
Example 5
private void initRefresh() {
        disposable = Observable.interval(0, 1, TimeUnit.SECONDS)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<Long>() {
                    @Override
                    public void accept(@NonNull Long aLong) throws Exception {
                        refreshData();
                    }
                });
    }
Example 6
public <T> ObservableTransformer<T, T> IoMain() {
        return new ObservableTransformer<T, T>() {
            @Override
            public ObservableSource<T> apply(io.reactivex.Observable<T> upstream) {
                return upstream.compose(CacheTransformer.<T>emptyTransformer()).
                        subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread());
            }
        };
    }
Example 7
private void createObservable() {
        Observable<List<String>> booksObservable =
                Observable.fromCallable(() -> restClient.getFavoriteBooks());
        bookSubscription = booksObservable.
                subscribeOn(Schedulers.io()).
                observeOn(AndroidSchedulers.mainThread()).
                subscribe(strings -> displayBooks(strings));
    }
Example 8
private void saveToStorage(final Location coordinates) {
        Schedulers.io().scheduleDirect(() -> {
            DataStore.saveTrailpoint(coordinates);
        });
    }
Example 9
public void removeInCall(InCall inCall) {
        Observable.just(inCall).observeOn(Schedulers.io()).subscribe(new Consumer<InCall>() {
            @Override
            public void accept(InCall inCall) {
                try {
                    mDataStore.delete(inCall);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
Example 10
private File saveToTmpFile(String text) {
        try {
            File tmp = TmpScriptFiles.create(this);
            Observable.just(text)
                    .observeOn(Schedulers.io())
                    .subscribe(t -> PFiles.write(tmp, t));
            return tmp;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
Example 11
public static Observable<List<String>> getPathList(final File file, final boolean recursive, final boolean inSameDir) {
        return Observable.fromCallable(
                () -> walk(file, new ArrayList<>(), recursive, inSameDir))
                .subscribeOn(Schedulers.io());
    }
Example 12
public Observable<List<Bookmark>> getBookmarkedAyahsOnPageObservable(Integer... pages) {
    return Observable.fromArray(pages)
        .map(bookmarksDBAdapter::getBookmarkedAyahsOnPage)
        .filter(bookmarks -> !bookmarks.isEmpty())
        .subscribeOn(Schedulers.io());
  }
Example 13
public Observable<Long> safeAddBookmark(final Integer sura, final Integer ayah, final int page) {
    return Observable.fromCallable(() -> {
      long result = bookmarksDBAdapter.addBookmarkIfNotExists(sura, ayah, page);
      bookmarksPublishSubject.onNext(true);
      return result;
    }).subscribeOn(Schedulers.io());
  }
Example 14
private Observable<JsonElement> revokeSingleToken(String authHeader, RevokeReqBody reqBody,
                                                      Observer<JsonElement> observer) {
        return mApi.revokeAuthToken(authHeader, reqBody)
                    .subscribeOn(Schedulers.io())
                    .observeOn(Schedulers.io())
                .map(res -> checkRevocationResponse(res, reqBody.tokenTypeHint))
                .doOnNext(observer::onNext)
                .doOnError(e -> wrapInTokenRevocationFailedException(e, reqBody.tokenTypeHint));
    }
Example 15
public void createTableRows(final Context context,
                                String tableName, Consumer<List<TableRow>> subscriber) {
        subscriptions.add(getUseCase().fetchRecords(tableName)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .map(new Function<Cursor, List<TableRow>>() {
                    @Override
                    public List<TableRow> apply(Cursor cursor) throws Exception {
                        return getTableRows(context, cursor);
                    }
                })
                .subscribe(subscriber));
    }
Example 16
private Observable<Address> getAddressFromLocation(Location location) {
        return rxLocation.geocoding().fromLocation(location).toObservable()
                .subscribeOn(Schedulers.io());
    }
Example 17
public void downloadFile(View view) {
        disposables.add(getCompletable()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(getDisposableObserver()));
    }
Example 18
public Single<Integer> deleteSearchHistory(final String search) {
        return Single.fromCallable(() -> searchHistoryTable.deleteAllWhereQuery(search))
                .subscribeOn(Schedulers.io());
    }
Example 19
private void subscribeEvent(Class aClass) {
        disposable = toFlowable(aClass).subscribeOn(Schedulers.io()).observeOn(ThreadMode.getScheduler
                (thread)).subscribe(new Consumer<Object>() {
            @Override
            public void accept(Object event) throws Exception {
                try {
                    handleEvent(event);
                    dellSticky(event);
                } catch (InvocationTargetException e) {
                    throwRuntimeException("Could not dispatch event: " + event.getClass() + " to subscriber " + EventSubscriber.this, e);
                }
            }
        });
    }
Example 20
public static <T> ObservableTransformer<T, T> norTransformer() {
        return new ObservableTransformer<T, T>() {
            @Override
            public ObservableSource<T> apply(Observable<T> apiResultObservable) {
                return apiResultObservable
                        .subscribeOn(Schedulers.io())
                        .unsubscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                        .retryWhen(new ApiRetryFunc(HttpGlobalConfig.getInstance().getRetryCount(),
                                HttpGlobalConfig.getInstance().getRetryDelayMillis()));
            }
        };
    }
Example 21
private void saveSearchToDb(List<SearchBookBean> newDataS) {
        Observable.create(e -> {
            DbHelper.getInstance().getmDaoSession().getSearchBookBeanDao()
                    .insertOrReplaceInTx(newDataS);
            e.onNext(true);
            e.onComplete();
        })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe();
    }
Example 22
public void removeCaller(Caller caller) {
        Observable.just(caller).observeOn(Schedulers.io()).subscribe(new Consumer<Caller>() {
            @Override
            public void accept(Caller caller) {
                mDataStore.delete(caller);
            }
        });
    }
Example 23
protected void doSomething() {
        Observable.just("1", "2", "3")
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<String>() {
                    @Override
                    public void accept(@NonNull String s) throws Exception {
                        mRxOperatorsText.append("accept : onNext : " + s + "\n");
                        Log.e(TAG,"accept : onNext : " + s + "\n" );
                    }
                });
    }
Example 24
public void removeRecord(MarkedRecord record) {
        Observable.just(record).observeOn(Schedulers.io()).subscribe(new Consumer<MarkedRecord>() {
            @Override
            public void accept(MarkedRecord record) {
                mDataStore.delete(record);
                removeCaller(findCallerSync(record.getNumber()));
            }
        });
    }
Example 25
public void loadTables(Consumer<List<TableItem>> subscriber) {
        subscriptions.add(getUseCase().fetchDatabaseTables()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber));
    }