Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Learn RxJava

Learn RxJava

In this example you can understand different elements of Rxjava with Strings.

Simple
This method creates an Observable such that when an Observer subscribes, the onNext() of the Observer is immediately called with the argument provided to Observable.just(). The onCompleted() will then be called since the Observable has no other values to emit.

Observable.create(subcriber ->{
        subcriber.onNext("Hello");
        subcriber.onNext("Javier Gonzalez");
        subcriber.onCompleated();
    });

Now with Exception:

    Observable.create(subcriber ->{
        subcriber.onNext("Hello");
        subcriber.onNext("Javier Gonzalez");
        subcriber.onError(new Exception("iOS user now allowed"));
    });

And there are another different ways to do:

    Observable.just("Hello again...");

    Observable.from(Arrays.asList("Hello", "again..."));

    Observable.from(new String[]{"Hello", "again..."});

    Observable.concat(Observable.just("Hello"), Observable.just("again..."));

    Observable.merge(Observable.just("Hello", "again..."), Observable.never());

Also you can check this example
And this post

The post Learn RxJava appeared first on The Developer World Is Yours.



This post first appeared on The Developer World Is Yours. Android, Magento & E, please read the originial post: here

Share the post

Learn RxJava

×

Subscribe to The Developer World Is Yours. Android, Magento & E

Get updates delivered right to your inbox!

Thank you for your subscription

×