@Override public void onNext(T t) { PushSubscriber.this.onNext(t); }
protected <U> ReactiveSeq<U> of(U... array){ return Spouts.async(s->{ Thread t = new Thread(()-> { for (U next : array) { s.onNext(next); } s.onComplete(); }); t.start(); }); }
protected <U> ReactiveSeq<U> of(U... array){ return Spouts.async(s->{ Thread t = new Thread(()-> { for (U next : array) { s.onNext(next); } s.onComplete(); }); t.start(); }); } protected ReactiveSeq<Integer> range(int start,int end){
protected <U> ReactiveSeq<U> of(U... array){ return Spouts.async(s->{ Thread t = new Thread(()-> { for (U next : array) { s.onNext(next); } s.onComplete(); }); t.start(); }); } protected ReactiveSeq<Integer> range(int start,int end){
protected <U> ReactiveSeq<U> of(U... array){ return Spouts.async(s->{ Thread t = new Thread(()-> { for (U next : array) { s.onNext(next); } s.onComplete(); }); t.start(); }); } @Test
protected <U> ReactiveSeq<U> of(U... array){ return Spouts.async(s->{ Thread t = new Thread(()-> { for (U next : array) { s.onNext(next); } s.onComplete(); }); t.start(); }); } @Test
protected <U> ReactiveSeq<U> of(U... array){ return Spouts.async(s->{ Thread t = new Thread(()-> { for (U next : array) { s.onNext(next); } s.onComplete(); }); t.start(); }); } @Test
protected <U> ReactiveSeq<U> of(U... array){ return Spouts.async(s->{ Thread t = new Thread(()-> { for (U next : array) { s.onNext(next); } s.onComplete(); }); t.start(); }); } protected ReactiveSeq<Integer> range(int start, int end){
protected ReactiveSeq<Integer> range(int start, int end){ return Spouts.async(s->{ Thread t = new Thread(()-> { for (int i =start;i<end;i++) { s.onNext(i); } s.onComplete(); }); t.start(); }); } protected <U> ReactiveSeq<U> rs(U... array){
protected <U> ReactiveSeq<U> of(U... array){ return Spouts.async(s->{ Thread t = new Thread(()-> { for (U next : array) { s.onNext(next); } s.onComplete(); }); t.start(); }); } ScheduledExecutorService ex =Executors.newScheduledThreadPool(1);
protected <U> ReactiveSeq<U> of(U... array){ return Spouts.async(s->{ Thread t = new Thread(()-> { for (U next : array) { s.onNext(next); } s.onComplete(); }); t.start(); }); }
public <T> Folds<T> of(T... values){ return Spouts.<T>async(s->{ Thread t = new Thread(()-> { for (T next : values) { s.onNext(next); } s.onComplete(); }); t.start(); }); }
protected <U> ReactiveSeq<U> of(U... array){ return Spouts.async(s->{ Thread t = new Thread(()-> { for (U next : array) { s.onNext(next); } s.onComplete(); }); t.start(); }); }
protected <U> ReactiveSeq<U> of(U... array){ return Spouts.async(s->{ Thread t = new Thread(()-> { for (U next : array) { s.onNext(next); } s.onComplete(); }); t.start(); }); } @Test
protected <U> ReactiveSeq<U> of(U... array){ return Spouts.async(s->{ Thread t = new Thread(()-> { for (U next : array) { s.onNext(next); } s.onComplete(); }); t.start(); }); } @Test
protected <U> ReactiveSeq<U> of(U... array){ int[] index = {0}; return Spouts.async(s->{ new Thread(()-> { for (U next : array) { s.onNext(next); if(index[0]++>100) break; } s.onComplete(); }).start(); }); } @Test
protected <U> ReactiveSeq<U> of(U... array){ int[] index = {0}; return Spouts.async(s->{ new Thread(()-> { for (U next : array) { boolean sent = false; while(!sent) { try { s.onNext(next); sent = true; if (index[0]++ > 100) break; } catch (NullPointerException e) { //reactive-streams subscription may not initialized } } } s.onComplete(); }).start(); }); }
@Test public void iteratorTest(){ for(int x=100;x<10000;x=x+1000) { Set<Integer> result = new HashSet<>(x); int max = x; Iterator<Integer> it = Spouts.<Integer>async(sub -> { for (int i = 0; i < max; i++) { sub.onNext(i); } sub.onComplete(); }).iterator(); while (it.hasNext()) { result.add(it.next()); } assertThat(result.size(),equalTo(x)); } }
@Test public void asyncBufferBlock() throws InterruptedException { Subscription sub = Spouts.asyncBufferBlock(10, s -> { if (i == 0) { Effect e = () -> { s.onNext("hello " + i++); }; e.cycle(30).runAsync(); } } ).forEach(2, in->count++); Thread.sleep(500); sub.request(30); Thread.sleep(500); assertThat(i,equalTo(30)); assertThat(count,equalTo(30)); } @Test