FHIR Chat · RxJava support · hapi

Stream: hapi

Topic: RxJava support


view this post on Zulip Raed Cran (Nov 03 2018 at 15:52):

Hi, is there any plan for supporting RxJava library? @James Agnew

view this post on Zulip James Agnew (Nov 05 2018 at 08:57):

@Raed Cran Well.. No current plans. Not that it's not a great idea (I love the reactive paradigm) but I don't think anyone is working on this now.

Any interest in taking this on? :)

view this post on Zulip Grahame Grieve (Nov 05 2018 at 20:34):

What would it mean to support rxjava?

view this post on Zulip Raed Cran (Nov 06 2018 at 00:14):

@James Agnew yep, I would love to, but I'm not an expert in reactive programming. But certainly I would join a team taking this. thanks for the answer :)

@Grahame Grieve
I was thinking of something similar to Retrofit RxJava2 adapter (https://github.com/square/retrofit/tree/master/retrofit-adapters/rxjava2), a more integrated reactive functionality into the rest client.
Per example, the possibility of returning an Observable<Bundle> instead of just a raw Bundle, and switch between threads, that is very important in Android (my case).

I realized I could achieve this right now with RxJava 2, here is a simple example:

            Observable.just(newText)
                .subscribeOn(Schedulers.io())
                .map(t -> client.search()
                        .forResource(Patient.class)
                        .where(Patient.FAMILY.matches().value(t))
                        .returnBundle(org.hl7.fhir.dstu3.model.Bundle.class)
                        .summaryMode(SummaryEnum.TRUE)
                        .execute())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(b -> {
                    adapter.clear();
                    if (!b.getEntry().isEmpty()) {
                        adapter.addAll(b.getEntry());
                    }
                });

But it feels not so fluid as it could be, It would be interesting if I could do something like this:

        client.search()
                .forResource(Patient.class)
                .where(Patient.FAMILY.matches().value(t))
                .returnBundle(org.hl7.fhir.dstu3.model.Bundle.class)
                .toObservable() //returns Observable<Bundle>
                .subscribeOn(Schedulers.io()) //  IO-bound work thread.
                .observeOn(AndroidSchedulers.mainThread()) // ui update on UI thread
                .subscribe(b -> {
                    adapter.clear();
                    if (!b.getEntry().isEmpty()) {
                        adapter.addAll(b.getEntry());
                    }
                }).execute();

view this post on Zulip Grahame Grieve (Nov 06 2018 at 05:59):

does rxjava have an extensibility framework for stuff like this?


Last updated: Apr 12 2022 at 19:14 UTC