All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.aksw.commons.rx.util.FlowBase Maven / Gradle / Ivy

There is a newer version: 0.9.9
Show newest version
package org.aksw.commons.rx.util;

import org.reactivestreams.Subscription;

import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.FlowableEmitter;
import io.reactivex.rxjava3.core.FlowableSubscriber;

/**
 * Utility base class for FlowableSubscribers which wraps a FlowableEmitter.
 *
 * There may be a similar base class in the RxJava framework itself, however so far I did not find it ~ Claus
 *
 * @author raven
 *
 * @param 
 */
public abstract class FlowBase
    implements FlowableSubscriber
{
    protected FlowableEmitter emitter;

    public FlowBase(FlowableEmitter emitter) {
        super();
        this.emitter = emitter;
    }

    @Override
    public void onError(Throwable t) {
        emitter.onError(t);
    }

    @Override
    public void onSubscribe(@NonNull Subscription s) {
        emitter.setCancellable(s::cancel);
        s.request(Long.MAX_VALUE);
    }

    @Override
    public void onComplete() {
        emitter.onComplete();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy