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
| public class RxOperatorRepeat { | |
| public static void main(String[] args) { | |
| Observable.just("Hello world") | |
| .repeat(5) | |
| .subscribe(System.out::println); | |
| } | |
| } |
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
| public class RxOperatorStart { | |
| public static void main(String[] args) { | |
| Observable.just("Hello World") | |
| .startWith("RxJava") | |
| .subscribe(System.out::println); | |
| } | |
| } |
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
| public class RxOperatorTimer { | |
| public static void main(String[] args) throws InterruptedException { | |
| CountDownLatch countDownLatch = new CountDownLatch(1); | |
| Observable.timer(1000 * 2, TimeUnit.MILLISECONDS) | |
| .subscribe(new Observer<Long>() { | |
| @Override | |
| public void onSubscribe(Disposable d) { | |
| System.out.println("onSubscribe"); | |
| } |
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
| public class RxTransformingOperatorBuffer { | |
| public static void main(String[] args) throws InterruptedException { | |
| String[] names = new String[]{"Yudi Setiawan", "Rosalia", "Harli Lopies", "Fitriani"}; | |
| Observable.fromArray(names) | |
| .buffer(3) | |
| .subscribe(System.out::println); | |
| } | |
| } |
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
| public class RxTransformingOperatorFlatMap { | |
| public static void main(String[] args) { | |
| String[] names = new String[]{"Yudi Setiawan", "Rosalia", "Harli Lopies", "Fitriani"}; | |
| Observable.just(names) | |
| .flatMap((Function<String[], ObservableSource<String>>) Observable::fromArray) | |
| .subscribe(System.out::println); | |
| } | |
| } |
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
| public class RxTransformingOperatorGroupBy { | |
| public static void main(String[] args) { | |
| Observable.range(1, 9) | |
| .groupBy(item -> item % 2 == 0 ? "Genap" : "Ganji") | |
| .subscribe(groupObservable -> { | |
| if (groupObservable.getKey().equalsIgnoreCase("Genap")) { | |
| System.out.println("Emit bilangan genap"); | |
| System.out.println("List bilangan genap adalah sebagai berikut."); | |
| groupObservable.subscribe(System.out::println); | |
| } else { |
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
| public class RxTransformingOperatorMap { | |
| public static void main(String[] args) { | |
| Observable.range(1, 10) | |
| .map(integer -> integer + " merupakan Bilangan " + (integer % 2 == 0 ? "Genap" : "Ganjil")) | |
| .subscribe(System.out::println); | |
| } | |
| } |
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
| public class RxTransformingOperatorScan { | |
| public static void main(String[] args) { | |
| Observable.just(1, 2, 3, 4, 5) | |
| .scan((resultObserverPrevious, item) -> { | |
| System.out.println("x: " + resultObserverPrevious + " & y: " + item); | |
| return resultObserverPrevious + item; | |
| }) | |
| .subscribe(System.out::println); | |
| } | |
| } |
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
| public class RxTransformingOperatorWindow { | |
| public static void main(String[] args) { | |
| Observable.range(1, 10) | |
| .window(3) | |
| .subscribe(longObservable -> { | |
| System.out.println("starting new window"); | |
| longObservable.subscribe(aLong -> System.out.println("window item " + aLong), | |
| throwable -> System.out.println("window error"), | |
| () -> System.out.println("window completed") | |
| ); |
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
| import 'package:auto_size_text/auto_size_text.dart'; | |
| import 'package:flutter/material.dart'; | |
| void main() => runApp(MainApp()); | |
| class MainApp extends StatefulWidget { | |
| @override | |
| CalculatorAppState createState() => CalculatorAppState(); | |
| } |