RxState

Additional

Language
Java
Version
N/A
Created
Jan 3, 2017
Updated
Jan 8, 2017 (Retired)
Owner
Konstantin Mikheev (konmik)
Activity
Badge
Generate
Download
Source code

Advertisement

RxState

This project is implementation of ideas from Managing state reactive way article.

RxJava1 dependency

dependencies {
    compile 'com.konmik.rxstate:rxstate1:0.1.0-beta1'
}
RxJava2 dependency

dependencies {
    compile 'com.konmik.rxstate:rxstate2:0.1.0-beta1'
}

Usage

Code (RxJava1):

    RxState<Integer> state = new RxState<>(0, Schedulers.immediate());
    state.values(StartWith.SCHEDULE)
            .subscribe(it -> System.out.println(it));
    state.apply(it -> it + 1);

Code (RxJava2):

    RxState<Integer> state = new RxState<>(0, Schedulers.single());
    state.values(StartWith.SCHEDULE)
            .subscribe(it -> System.out.println(it));
    state.apply(it -> it + 1);

Prints:

0
1