Construct a safe reactive type instance which when subscribed to by a consumer, runs an user-provided function and provides a type-specific
Emitter
for this function to generate the signal(s) the designated business logic requires. This method allows bridging the non-reactive, usually listener/callback-style world, with the reactive world.
Observable<String> observable = Observable.create(emitter -> { emitter.onNext("1"); emitter.onNext("2"); emitter.onComplete(); }); observable.subscribe(s -> { System.out.println(s); });
References
https://www.vogella.com/tutorials/RxJava/article.html#creating-observables
https://www.tutorialspoint.com/rxjava/rxjava_creating_operators.htm
https://github.com/ReactiveX/RxJava/wiki/Creating-Observables#create