
- RxJava Tutorial
- RxJava - Home
- RxJava - Overview
- RxJava - Environment Setup
- Observables
- RxJava - How Observable works
- RxJava - Creating Observables
- RxJava - Single Observable
- RxJava - MayBe Observable
- RxJava - Completable Observable
- RxJava - Using CompositeDisposable
- Operators
- RxJava - Creating Operators
- RxJava - Transforming Operators
- RxJava - Filtering Operators
- RxJava - Combining Operators
- RxJava - Utility Operators
- RxJava - Conditional Operators
- RxJava - Mathematical Operators
- RxJava - Connectable Operators
- Subjects
- RxJava - Subjects
- RxJava - PublishSubject
- RxJava - BehaviorSubject
- RxJava - ReplaySubject
- RxJava - AsyncSubject
- Schedulers
- RxJava - Schedulers
- RxJava - Trampoline Scheduler
- RxJava - NewThread Scheduler
- RxJava - Computation Scheduler
- RxJava - IO Scheduler
- RxJava - From Scheduler
- Miscellaneous
- RxJava - Buffering
- RxJava - Windowing
- RxJava Useful Resources
- RxJava - Quick Guide
- RxJava - Useful Resources
- RxJava - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
RxJava - Utility Operators
Following are the operators which are often useful with Observables.
Sr.No. | Operator & Description |
---|---|
1 | Delay Register action to handle Observable life-cycle events. |
2 | Materialize/Dematerialize Represents item emitted and notification sent. |
3 | ObserveOn Specify the scheduler to be observed. |
4 | Serialize Force Observable to make serialized calls. |
5 | Subscribe Operate upon the emissions of items and notifications like complete from an Observable |
6 | SubscribeOn Specify the scheduler to be used by an Observable when it is subscribed to. |
7 | TimeInterval Convert an Observable to emit indications of the amount of time elapsed between emissions. |
8 | Timeout Issues error notification if specified time occurs without emitting any item. |
9 | Timestamp Attach timestamp to each item emitted. |
9 |
Using Creates a disposable resource or same lifespan as that of Observable. |
Utility Operator Example
Create the following Java program using any editor of your choice in, say, C:\> RxJava.
ObservableTester.java
import io.reactivex.Observable; //Using subscribe operator to subscribe to an Observable public class ObservableTester { public static void main(String[] args) { String[] letters = {"a", "b", "c", "d", "e", "f", "g"}; final StringBuilder result = new StringBuilder(); Observable<String> observable = Observable.fromArray(letters); observable.subscribe( letter -> result.append(letter)); System.out.println(result); } }
Verify the Result
Compile the class using javac compiler as follows −
C:\RxJava>javac ObservableTester.java
Now run the ObservableTester as follows −
C:\RxJava>java ObservableTester
It should produce the following output −
abcdefg