These are chat archives for ReactiveX/RxJava

Aug 2017
Aug 03 2017 18:19
Hi, I'm new to RxJava request help from the community on a scenario. I have SpringMVC setup, the RestController receives an object like "Person" with properties like FirstName, LastName..etc. The RestController needs to send back some information based on the object(Person) it receives and also in parallel make entry to the DB that this particular query about object(Person) was received. Now return from the RestController does not have to wait for DB entry to be complete, these are 2 parallel operations. Is RxJava suitable for such a scenario? If yes, how could it be used?
Rafat J. Al-Barouki
Aug 03 2017 22:01
Observable<Person> personObservable = Observable.just(new Person()).subscribeOn(;
        personObservable.subscribe(person -> {
            // gets the data and return it by the controller
        personObservable.subscribe(person -> {
            // add the object to the database
try to do this
this will execute the two operations in two threads
so they will be executed in parallel and with no waiting
and if your method returns a value then you can do this
Person person = new Person();
        Observable<Person> personObservable = Observable.just(person).subscribeOn(;
        personObservable.subscribe(p -> {
            // add the object to the database
        // gets the data and return it