Last active
March 12, 2018 20:48
-
-
Save helloseyedjafari/faff605bc3ae19710088b650797818ee to your computer and use it in GitHub Desktop.
Reactive Extensions Persuasion part_1
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 characters
| Observable.range(0, 50) | |
| .buffer(10) | |
| .subscribe(integers -> { | |
| Log.d("tag", "list size recevied after buffering: "+integers.size()); | |
| }); |
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 characters
| Observable.create(searchEvents) | |
| .throttle(10, TimeUnit.SECONDS) | |
| .subscribe(new Consumer<events>() { | |
| @Override | |
| public void accept(Events events) throws Exception { | |
| } | |
| }); |
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 characters
| List<Integer> ints = Arrays.asList(1, 4, 7, 5, 1, 5, 4, 5, 1, 7); | |
| Observable.fromIterable(ints) | |
| .distinct() | |
| .filter(integer-> integer % 2 == 0) | |
| .subscribe(); | |
| Observable.create(new ObservableOnSubscribe<String>() { | |
| @Override | |
| public void subscribe(ObservableEmitter<String> e) throws Exception { | |
| for (int i = 0; i > 10; i++) { | |
| e.onNext("example No:." + i); | |
| } | |
| e.onComplete(); | |
| } | |
| }).toList() | |
| .map(new Function<List<String>, String>() { | |
| @Override | |
| public String apply(List<String> strings) throws Exception { | |
| return strings.toString(); | |
| } | |
| }).subscribe(); |
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 characters
| Observable.just("Schedulers Test") | |
| .subscribeOn(Schedulers.computation()) | |
| .subscribeOn(Schedulers.io()) | |
| .subscribeOn(Schedulers.single()) | |
| .subscribeOn(Schedulers.newThread()) | |
| .observeOn(AndroidSchedulers.mainThread()) | |
| .subscribe(new Consumer<String>() { | |
| @Override | |
| public void accept(String s) throws Exception { | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment