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

cyclops.streams.RxOperators Maven / Gradle / Ivy

There is a newer version: 9.0.0-MI7
Show newest version
package cyclops.streams;

import cyclops.companion.rx.Observables;
import cyclops.stream.ReactiveSeq;
import rx.Observable;
import rx.Subscriber;

import java.util.function.Function;

/*
 * Extensions for leveraging Rx Observable operators with cyclops-react ReactiveSeq instances
 *
 * 
 * {@code
 *   ReactiveSeq.of(1,2,3)
                .to(lift(new Observable.Operator(){


                    @Override
                    public Subscriber call(Subscriber subscriber) {
                        return subscriber; // operator code
                    }
                            }))
                   .map(i->i+1)
                   .to(observable(o->o.buffer(10)));

   }
 * 
* */ public class RxOperators { public static Function,ReactiveSeq> lift(final Observable.Operator operator){ return s->Observables.reactiveSeq(Observables.observableFrom(s).lift(operator)); } public static Function,ReactiveSeq> observable(final Function,? extends Observable> fn){ return s->Observables.reactiveSeq(Observables.narrow(fn.apply(Observables.observableFrom(s)))); } public static Function,Observable> seq(final Function,? extends ReactiveSeq> fn){ return s-> Observables.observableFrom((ReactiveSeq)fn.apply(Observables.reactiveSeq(s))); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy