Java Code Examples for io.reactivex.Observable#toFlowable()

The following examples show how to use io.reactivex.Observable#toFlowable() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public Object adapt(Call<R> call) {
    Observable<Response<R>> responseObservable = mAsync
            ? new CallEnqueueObservable<>(mCachingSystem, call, mResponseType, mAnnotations, mRetrofit)
            : new CallExecuteObservable<>(mCachingSystem, call, mResponseType, mAnnotations, mRetrofit);

    Observable<?> observable;
    if (mResult) {
        observable = new ResultObservable<>(responseObservable);
    } else if (mBody) {
        observable = new BodyObservable<>(responseObservable);
    } else {
        observable = responseObservable;
    }

    if (mScheduler != null) {
        observable = observable.subscribeOn(mScheduler);
    }

    if (mFlowable) {
        return observable.toFlowable(BackpressureStrategy.LATEST);
    }
    if (mSingle) {
        return observable.singleOrError();
    }
    if (mMaybe) {
        return observable.singleElement();
    }
    if (mCompletable) {
        return observable.ignoreElements();
    }
    return observable;
}
 
Example 2
Source Project: graphql-spqr   File: SubscriptionTest.java    License: Apache License 2.0 5 votes vote down vote up
@GraphQLSubscription
public Publisher<Integer> tick() {
    Observable<Integer> observable = Observable.create(emitter -> {
        emitter.onNext(1);
        Thread.sleep(1000);
        emitter.onNext(2);
        Thread.sleep(1000);
        emitter.onComplete();
    });

    return observable.toFlowable(BackpressureStrategy.BUFFER);
}
 
Example 3
@SuppressWarnings("unchecked")
@Override
public <T> Publisher<T> toRSPublisher(Observable instance) {
    return instance.toFlowable(BackpressureStrategy.MISSING);
}
 
Example 4
Source Project: tutorials   File: FlowableIntegrationTest.java    License: MIT License 4 votes vote down vote up
@Test public void whenFlowableIsCreatedFromObservable_thenItIsProperlyInitialized() throws InterruptedException {
    Observable<Integer> integerObservable = Observable.just(1, 2, 3);
    Flowable<Integer> integerFlowable = integerObservable.toFlowable(BackpressureStrategy.BUFFER);
    assertNotNull(integerFlowable);

}