Learning RxJava (for Android) by example

By: InfoQ

824   20   71502

Uploaded on 06/29/2015

A presentation aimed at beginners who have heard about RxJava and want to see what all the fuss is about. Kaushik Gopal provides primers on RxJava and RxAndroid, then looks at implementing real-world use cases in Android with RxJava.

He also imparts this valuable piece of advice, the best way to learn something is to just starting doing it!

--- Additional Resources from NewCircle ---

* Instructor-led Android Training: http://bit.ly/1Lf7rLv

* Android Resources & Videos: http://bit.ly/1R0gSna

http://www.meetup.com/sfandroid/

Comments (4):

By anonymous    2017-09-20

You can use something like this:

private final BehaviorSubject<Integer> subject = BehaviorSubject.create();
private Integer value=0;

public Observable<Integer> getUiElementAsObservable() {
    return subject;
}

public void updateUiElementValue(final Integer valueAdded) {
    synchronized (value) {
        if (value + valueAdded < 0)
            return;
        value += valueAdded;
        subject.onNext(value);
    }
}

and subscribe to it like this:

compositeSubscription.add(yourClass.getUiElementAsObservable()
            .subscribe(new Action1<Integer>() {
                @Override
                public void call(Integer userMessage) {
                    setViews(userMessage,true);
                }
            }));

you have to create setter for all of your variables that you want something subscribe to their changes and call onNext if change applied.

****UPDATE****

When an observer subscribes to a BehaviorSubject, it begins by emitting the item most recently emitted by the source Observable

you can see other type of subjects here: http://reactivex.io/documentation/subject.html

some useful link: about reactive programming : https://gist.github.com/staltz/868e7e9bc2a7b8c1f754 and about rxjava : https://youtu.be/k3D0cWyNno4

Original Thread

By anonymous    2017-09-20

I think you will benefit from learning to use RxJava / RxAndroid.

I believe that this presentation (and a video link) will help you with a solution, he was presenting a solution to a similar problem.

If you never used RxJava before perhaps you should start with his first presentation and video.

Good Luck!

Original Thread

Popular Videos 730

Submit Your Video

If you have some great dev videos to share, please fill out this form.