use of com.oath.cyclops.anym.AnyMSeq in project cyclops by aol.
the class RxTest method anyMAsync.
@Test
public void anyMAsync() {
AtomicBoolean complete = new AtomicBoolean(false);
ReactiveSeq<Integer> asyncSeq = Spouts.async(Stream.of(1, 2, 3), Executors.newFixedThreadPool(1));
Observable<Integer> observableAsync = Observables.observableFrom(asyncSeq);
AnyMSeq<observable, Integer> monad = Observables.anyM(observableAsync);
monad.map(i -> i * 2).forEach(System.out::println, System.err::println, () -> complete.set(true));
System.out.println("Blocked? " + complete.get());
while (!complete.get()) {
Thread.yield();
}
Observable<Integer> converted = ObservableAnyM.raw(monad);
}
use of com.oath.cyclops.anym.AnyMSeq in project cyclops by aol.
the class AbstractAnyMSeqTest method testShuffleRandom.
@Test
public void testShuffleRandom() {
Random r = new Random();
Supplier<AnyMSeq<W, Integer>> s = () -> of(1, 2, 3);
assertEquals(3, s.get().shuffle(r).to(ReactiveConvertableSequence::converter).listX().size());
assertThat(s.get().shuffle(r).to(ReactiveConvertableSequence::converter).listX(), hasItems(1, 2, 3));
}
Aggregations