RxJava: Difference between revisions
Jump to navigation
Jump to search
Line 9: | Line 9: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=Observable Types= | =Observable Types= | ||
==Singles== | ==Singles== |
Revision as of 04:25, 10 February 2022
Introduction
These are notes on RxJava which I have used with Android/Kotlin. To use with Android at the time you specify the following
dependencies {
...
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
implementation 'io.reactivex.rxjava3:rxjava:3.0.13'
...
}
Observable Types
Singles
Single is an Observable which only emits one item or throws an error. Single emits only one value and applying some of the operator makes no sense. Like we don’t want to take value and collect it to a list.
interface SingleObserver<T> {
void onSubscribe(Disposable d);
void onSuccess(T value);
void onError(Throwable error);
}
Maybes
Completables
Because we are using java we have 3 types of observables,
- Completables
- Singles
- Maybes
This restricts the functions we need to implement.