android - Getting Header information with RXJava and Retrofit -



android - Getting Header information with RXJava and Retrofit -

i'm trying convert app uses retrofit, utilize rx java. in order handle pagination, traditionally grabbing nextpage url response headers.

@override public void success(assignment assignment, response response) { response.getheaders(); // stuff header info }

however, since switching rx java, i'm not sure how response info retrofit call.

@get("/{item_id}/users") observable<list<objects>> getobjects(@path("object_id") long object_id); @get("/{next}") observable<list<objects>> getnextpageobjects(@path("next") string nexturl);

is there way have retrofit calls homecoming header info along typed objects?

you can utilize

observable<response>

as homecoming type response details

@get("/{item_id}/users") observable<response> getobjects(@path("object_id") long object_id); @get("/{next}") observable<response>getnextpageobjects(@path("next") string nexturl);

this how response object

you have parse headers , body observable

serviceclass.getnextpageobjects("next").flatmap(new func1<response, observable<list<objects>>() { @override public observable<authstate> call(response response) { list<header> headers = response.getheaders(); gsonconverter converter = new gsonconverter(new gson()); // have alter convert objects list list<objects> list = converter.frombody(response.getbody(), yourclass.class); homecoming observable.from(list); } }

android retrofit rx-java

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -