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

cyclops.reactive.ObservableReactiveSeq Maven / Gradle / Ivy

There is a newer version: 10.4.0
Show newest version
package cyclops.reactive;

import com.oath.cyclops.rx2.adapter.ObservableReactiveSeqImpl;
import cyclops.companion.rx2.Observables;
import io.reactivex.Observable;
import io.reactivex.Scheduler;
import io.reactivex.schedulers.Schedulers;

import java.util.concurrent.TimeUnit;

/*
 Factory methods for creating Observable backed ReactiveSeq instances
 */
public interface ObservableReactiveSeq {

    public static  ReactiveSeq reactiveSeq(Observable observable) {
        return new ObservableReactiveSeqImpl<>(observable);
    }
    public static  ReactiveSeq empty() {
        return reactiveSeq(Observable.empty());
    }

    public static  ReactiveSeq error(Throwable exception) {
        return reactiveSeq(Observable.error(exception));
    }

    public static  ReactiveSeq from(Iterable iterable) {
        return reactiveSeq(Observable.fromIterable(iterable));
    }


    public static ReactiveSeq interval(long interval, TimeUnit unit) {
        return interval(interval, interval, unit, Schedulers.computation());
    }


    public static ReactiveSeq interval(long interval, TimeUnit unit, Scheduler scheduler) {
        return interval(interval, interval, unit, scheduler);
    }


    public static ReactiveSeq interval(long initialDelay, long period, TimeUnit unit) {
        return interval(initialDelay, period, unit, Schedulers.computation());
    }


    public static ReactiveSeq interval(long initialDelay, long period, TimeUnit unit, Scheduler scheduler) {
        return reactiveSeq(Observable.interval(initialDelay,period,unit,scheduler));
    }


    public static  ReactiveSeq just(final T value) {
        return reactiveSeq(Observable.just(value));
    }
    @SafeVarargs
    public static  ReactiveSeq just(final T... values) {
        T[] array = values;
        return reactiveSeq(Observable.fromArray(array));
    }
    public static  ReactiveSeq of(final T value) {
        return just(value);
    }
    @SafeVarargs
    public static  ReactiveSeq of(final T... values) {
        return just(values);
    }


    public static  ReactiveSeq merge(Iterable> sequences) {
        return merge(from(sequences));
    }


    public static  ReactiveSeq merge(Iterable> sequences, int maxConcurrent) {
        return merge(from(sequences), maxConcurrent);
    }

    public static  ReactiveSeq merge(Observable> source) {
        return reactiveSeq(Observable.merge(source));
    }


    public static  ReactiveSeq merge(Observable> source, int maxConcurrent) {
        return reactiveSeq(Observable.merge(source,maxConcurrent));
    }

    public static  ReactiveSeq mergeDelayError(Observable> source) {
        return reactiveSeq(Observable.mergeDelayError(source));
    }

    public static  ReactiveSeq mergeDelayError(Observable> source, int maxConcurrent) {
        return reactiveSeq(Observable.mergeDelayError(source,maxConcurrent));
    }

    public static  ReactiveSeq mergeDelayError(Iterable> sequences) {
        return mergeDelayError(from(sequences));
    }

    public static  ReactiveSeq mergeDelayError(Iterable> sequences, int maxConcurrent) {
        return mergeDelayError(from(sequences), maxConcurrent);
    }



    public static  ReactiveSeq never() {
        return reactiveSeq(Observable.never());
    }

    public static ReactiveSeq range(int start, int count) {
        return reactiveSeq(Observable.range(start,count));
    }



    public static  ReactiveSeq switchOnNext(Observable> sequenceOfSequences) {
        return reactiveSeq(Observable.switchOnNext(sequenceOfSequences));
    }


    public static  ReactiveSeq switchOnNextDelayError(Observable> sequenceOfSequences) {
        return reactiveSeq(Observable.switchOnNext(sequenceOfSequences));
    }


    public static ReactiveSeq timer(long initialDelay, long period, TimeUnit unit) {
        return interval(initialDelay, period, unit, Schedulers.computation());
    }


    public static ReactiveSeq timer(long delay, TimeUnit unit) {
        return timer(delay, unit, Schedulers.computation());
    }


    public static ReactiveSeq timer(long delay, TimeUnit unit, Scheduler scheduler) {
        return reactiveSeq(Observable.timer(delay,unit,scheduler));
    }



}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy