use of io.reactivex.Flowable in project jersey by jersey.
the class FlowableAgentResource method flowable.
@GET
public void flowable(@Suspended final AsyncResponse async) {
final long time = System.nanoTime();
final Queue<String> errors = new ConcurrentLinkedQueue<>();
Flowable.just(new AgentResponse()).zipWith(visited(errors), (agentResponse, visited) -> {
agentResponse.setVisited(visited);
return agentResponse;
}).zipWith(recommended(errors), (agentResponse, recommendations) -> {
agentResponse.setRecommended(recommendations);
return agentResponse;
}).observeOn(Schedulers.io()).subscribe(agentResponse -> {
agentResponse.setProcessingTime((System.nanoTime() - time) / 1000000);
async.resume(agentResponse);
}, async::resume);
}
use of io.reactivex.Flowable in project RxJava-Android-Samples by kaushikgopal.
the class RxBusDemo_Bottom2Fragment method onStart.
@Override
public void onStart() {
super.onStart();
_disposables = new CompositeDisposable();
Flowable<Object> tapEventEmitter = _rxBus.asFlowable().share();
_disposables.add(tapEventEmitter.subscribe(event -> {
if (event instanceof RxBusDemoFragment.TapEvent) {
_showTapText();
}
}));
Flowable<Object> debouncedEmitter = tapEventEmitter.debounce(1, TimeUnit.SECONDS);
Flowable<List<Object>> debouncedBufferEmitter = tapEventEmitter.buffer(debouncedEmitter);
_disposables.add(debouncedBufferEmitter.observeOn(AndroidSchedulers.mainThread()).subscribe(taps -> {
_showTapCount(taps.size());
}));
}
use of io.reactivex.Flowable in project RxJava by ReactiveX.
the class FlowableMergeDelayErrorTest method mergeMany.
@SuppressWarnings("unchecked")
@Test
@Ignore("No 2-9 parameter mergeDelayError() overloads")
public void mergeMany() throws Exception {
for (int i = 2; i < 10; i++) {
Class<?>[] clazz = new Class[i];
Arrays.fill(clazz, Flowable.class);
Flowable<Integer>[] obs = new Flowable[i];
Arrays.fill(obs, Flowable.just(1));
Integer[] expected = new Integer[i];
Arrays.fill(expected, 1);
Method m = Flowable.class.getMethod("mergeDelayError", clazz);
TestSubscriber<Integer> ts = TestSubscriber.create();
((Flowable<Integer>) m.invoke(null, (Object[]) obs)).subscribe(ts);
ts.assertValues(expected);
ts.assertNoErrors();
ts.assertComplete();
}
}
use of io.reactivex.Flowable in project RxJava by ReactiveX.
the class SchedulerWhenTest method testRaceConditions.
@Test(timeout = 1000)
public void testRaceConditions() {
Scheduler comp = Schedulers.computation();
Scheduler limited = comp.when(new Function<Flowable<Flowable<Completable>>, Completable>() {
@Override
public Completable apply(Flowable<Flowable<Completable>> t) {
return Completable.merge(Flowable.merge(t, 10));
}
});
merge(just(just(1).subscribeOn(limited).observeOn(comp)).repeat(1000)).blockingSubscribe();
}
use of io.reactivex.Flowable in project RxCache by VictorAlbertos.
the class ProxyTranslator method getLoaderObservable.
private Observable getLoaderObservable(Method method, Object[] objectsMethod) {
Observable<?> observable = getObjectFromMethodParam(method, Observable.class, objectsMethod);
if (observable != null)
return observable;
Single single = getObjectFromMethodParam(method, Single.class, objectsMethod);
if (single != null)
return single.toObservable();
Maybe maybe = getObjectFromMethodParam(method, Maybe.class, objectsMethod);
if (maybe != null)
return maybe.toObservable();
Flowable flowable = getObjectFromMethodParam(method, Flowable.class, objectsMethod);
if (flowable != null)
return flowable.toObservable();
String errorMessage = method.getName() + io.rx_cache2.internal.Locale.NOT_REACTIVE_TYPE_FOR_LOADER_WAS_FOUND;
throw new IllegalArgumentException(errorMessage);
}
Aggregations