This project is implementation of ideas from Managing state reactive way article.
dependencies {
compile 'com.konmik.rxstate:rxstate1:0.1.0-beta1'
}
dependencies {
compile 'com.konmik.rxstate:rxstate2:0.1.0-beta1'
}
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