private ReactiveSeq<Integer> nextAsync() { AsyncSubscriber<Integer> sub = Spouts.asyncSubscriber(); new Thread(()->{ sub.awaitInitialization(); try { //not a reactive-stream so we don't know with certainty when demand signalled Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } sub.onNext(1); sub.onNext(2); sub.onComplete(); }).start(); return sub.stream(); }
private ReactiveSeq<Integer> nextAsync() { AsyncSubscriber<Integer> sub = Spouts.asyncSubscriber(); new Thread(()->{ sub.awaitInitialization(); try { //not a reactive-stream so we don't know with certainty when demand signalled Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } sub.onNext(1); sub.onNext(2); sub.onComplete(); }).start(); return sub.stream(); } }
private Stream<Integer> nextAsync() { AsyncSubscriber<Integer> sub = Spouts.asyncSubscriber(); new Thread(()->{ sub.awaitInitialization(); try { //not a reactive-stream so we don't know with certainty when demand signalled Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } sub.onNext(1); sub.onNext(2); sub.onComplete(); }).start(); return sub.stream(); } }
private Stream<Integer> nextAsync() { AsyncSubscriber<Integer> sub = Spouts.asyncSubscriber(); new Thread(()->{ sub.awaitInitialization(); try { //not a reactive-stream so we don't know with certainty when demand signalled Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } sub.onNext(1); sub.onNext(2); sub.onComplete(); }).start(); return sub.stream(); } }
private ReactiveSeq<Integer> nextAsync() { AsyncSubscriber<Integer> sub = Spouts.asyncSubscriber(); new Thread(()->{ sub.awaitInitialization(); try { //not a reactive-stream so we don't know with certainty when demand signalled Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } sub.onNext(1); sub.onNext(2); sub.onComplete(); }).start(); return sub.stream(); } }
private ReactiveSeq<Integer> nextAsync() { AsyncSubscriber<Integer> sub = Spouts.asyncSubscriber(); new Thread(()->{ sub.awaitInitialization(); try { //not a reactive-stream so we don't know with certainty when demand signalled Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } sub.onNext(1); sub.onNext(2); sub.onComplete(); }).start(); return sub.stream(); } }
System.out.println("Setting up Stream!"); assertThat(sub.stream().peek(System.out::println).collect(Collectors.toList()).size(), equalTo(100));
@Test @Ignore public void limitLast(){ AsyncSubscriber<String> pushable = Spouts.asyncSubscriber(); ReactiveSeq<String> stream = pushable.stream(); pushable.onNext("hello1"); pushable.onNext("hello2"); pushable.onNext("hello3"); pushable.onComplete(); // stream.printOut(); stream.takeRight(2).zipWithStream(Stream.of(1,2)).printOut(); }