Java Code Examples for io.reactivex.schedulers.Schedulers#single()

The following examples show how to use io.reactivex.schedulers.Schedulers#single() . 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 Flowable<String> getEmpNamesRx() {
	Scheduler observerWorker = Schedulers.single();
	Scheduler subscriberWorker = Schedulers.newThread();
	Function<Employee, String> names = (emp) -> emp.getFirstName() + emp.getLastName();
	Flowable<String> emps = Flowable.fromIterable(employeeDaoImpl.getEmployees())
			.map(names).observeOn(observerWorker).subscribeOn(subscriberWorker);
	return emps;
}
 
Example 2
Source Project: Reactive-Android-Programming   File: Sandbox.java    License: MIT License 5 votes vote down vote up
private void demo0() {
    Schedulers.single();
    Schedulers.trampoline();
    Schedulers.newThread();
    Schedulers.computation();
    Schedulers.io();
    Schedulers.io();
}
 
Example 3
Source Project: Reactive-Android-Programming   File: Sandbox.java    License: MIT License 5 votes vote down vote up
private void demo0() {
    Schedulers.single();
    Schedulers.trampoline();
    Schedulers.newThread();
    Schedulers.computation();
    Schedulers.io();
    Schedulers.io();
}
 
Example 4
@Setup
public void setup() throws Exception {
    exec1 = Executors.newSingleThreadScheduledExecutor();
    exec2 = Executors.newSingleThreadScheduledExecutor();

    single1 = rx.schedulers.Schedulers.from(exec1);
    single2 = rx.schedulers.Schedulers.from(exec2);
    Scheduler single3 = Schedulers.single();
    Scheduler single4 = Schedulers.from(exec2);

    singleRa1 = reactor.core.scheduler.Schedulers.newSingle("A");
    singleRa2 = reactor.core.scheduler.Schedulers.newSingle("B");

    rxRange = rx.Observable.range(1, times);
    rxRangeFlatMapJust = rxRange.flatMap(rx.Observable::just);
    rxRangeFlatMapRange = rxRange.flatMap(v -> rx.Observable.range(v, 2));
    rxRangeAsync = rxRange.observeOn(single1);
    rxRangePipeline = rxRange.subscribeOn(single1).observeOn(single2);

    rx2Range = Flowable.range(1, times);
    rx2RangeFlatMapJust = rx2Range.flatMap(Flowable::just);
    rx2RangeFlatMapRange = rx2Range.flatMap(v -> Flowable.range(v, 2));
    rx2RangeAsync = rx2Range.observeOn(single3);
    rx2RangePipeline = rx2Range.subscribeOn(single3).observeOn(single4);

    raRange = Flux.range(1, times);
    raRangeFlatMapJust = raRange.flatMap(Flux::just);
    raRangeFlatMapRange = raRange.flatMap(v -> Flux.range(v, 2));
    raRangeAsync = raRange.publishOn(singleRa1);
    raRangePipeline = raRange.subscribeOn(singleRa1).publishOn(singleRa2);

    rscRange = Px.range(1, times);
    rscRangeFlatMapJust = rscRange.flatMap(Px::just);
    rscRangeFlatMapRange = rscRange.flatMap(v -> Px.range(v, 2));
    rscRangeAsync = rscRange.observeOn(exec1);
    rscRangePipeline = rscRange.subscribeOn(exec1).observeOn(exec2);

    values = rx2Range.toList().blockingGet();


    Config cfg = ConfigFactory.parseResources(ReactiveStreamsImpls.class, "/akka-streams.conf").resolve();
    actorSystem = ActorSystem.create("sys", cfg);

    materializer = ActorMaterializer.create(actorSystem);

    akRange = s -> {
        Source.range(1, times)
        .runWith(Sink.asPublisher(AsPublisher.WITHOUT_FANOUT), materializer)
        .subscribe(s);
    };

    akRangeFlatMapJust = s ->
            Source.range(1, times)
            .flatMapMerge(2, v -> Source.single(v))
            .runWith(Sink.asPublisher(AsPublisher.WITHOUT_FANOUT), materializer)
            .subscribe(s)
            ;

    akRangeFlatMapRange = s -> {
        Source.from(values)
        .flatMapMerge(2, v -> Source.range(v, v + 1))
        .runWith(Sink.asPublisher(AsPublisher.WITHOUT_FANOUT), materializer)
        .subscribe(s)
        ;
    };

    akRangeAsync = akRange;
    akRangePipeline = akRange;

    ak2Range = s -> {
        optimize(Source.range(1, times))
        .runWith(Sink.asPublisher(AsPublisher.WITHOUT_FANOUT), materializer)
        .subscribe(s);
    };

    ak2RangeFlatMapJust = s ->
            optimize(Source.range(1, times)
            .<Integer, NotUsed>flatMapMerge(2, v -> Source.single(v)))
            .runWith(Sink.asPublisher(AsPublisher.WITHOUT_FANOUT), materializer)
            .subscribe(s)
            ;

    ak2RangeFlatMapRange = s -> {
        optimize(Source.from(values)
        .<Integer, NotUsed>flatMapMerge(2, v -> Source.range(v, v + 1)))
        .runWith(Sink.asPublisher(AsPublisher.WITHOUT_FANOUT), materializer)
        .subscribe(s)
        ;
    };

    ak2RangeAsync = ak2Range;
    ak2RangePipeline = ak2Range;
}