Last active
January 18, 2018 01:46
-
-
Save abner/247e640d0360e8b717e5e47385d046ba to your computer and use it in GitHub Desktop.
Revisions
-
abner revised this gist
Jan 17, 2018 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,6 +10,8 @@ public class RxPlayground { public static void main(String[] args) { JsonArray jsonArray = new JsonArray().add(1).add(2).add(3); // toList => See http://tomstechnicalblog.blogspot.com.br/2015/11/rxjava-operators-tolist.html Object b = Observable .from(jsonArray.getList().toArray()) .switchMap(x -> @@ -22,7 +24,7 @@ public static void main(String[] args) { ((Single) b).subscribe(System.out::println); System.out.println(b); // Here, using Buffer operator Object c = Observable .from(jsonArray.getList().toArray()) .switchMap(x -> -
abner created this gist
Jan 17, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ import io.vertx.core.json.JsonArray; import rx.Observable; import rx.Single; /** * @author abner2 */ public class RxPlayground { public static void main(String[] args) { JsonArray jsonArray = new JsonArray().add(1).add(2).add(3); Object b = Observable .from(jsonArray.getList().toArray()) .switchMap(x -> doSome((Integer) x).toObservable() ) .toList() .toSingle() ; ((Single) b).subscribe(System.out::println); System.out.println(b); Object c = Observable .from(jsonArray.getList().toArray()) .switchMap(x -> doSome((Integer) x).toObservable() ) .buffer(jsonArray.size()) .toSingle() ; ((Single) c).subscribe(System.out::println); System.out.println(c); } public static Single<String> doSome(Integer ind) { return Single.just(new Integer(ind + 1).toString()); } }