Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import io.reactivex.Observable;
  2. import io.reactivex.observables.GroupedObservable;
  3. import java.util.concurrent.CountDownLatch;
  4. import java.util.concurrent.TimeUnit;
  5.  
  6. public class TypeTest {
  7. public static void main(String[] args) throws Exception {
  8. CountDownLatch latch = new CountDownLatch(1);
  9. Observable<Long> source Observable.interval(1,TimeUnit.MILLISECONDS).take(20);
  10. Observable<GroupedObservable<String,Long>> sgb =
  11. source.groupBy(x-> (x%2==0)?"Even":"Odd");
  12. // I'd like to introduce a variable for source.reduce but I get a type error.
  13. // Observable<Long> sreduce = source.reduce(new Long(0),(x,y)->(x+y));
  14. source.reduce(new Long(0),(x,y)->(x+y)).subscribe(
  15. x->{System.out.println(x);latch.countDown();}
  16. );
  17. latch.await();
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement