Fuel: How to merge requests

Created on 9 Oct 2018  路  1Comment  路  Source: kittinunf/fuel

like retrofit can use merge Operator Make multiple requests

question

Most helpful comment

Retrofit can actually not merge requests by itself. When using an extension, such as RxJava with retrofit, "merging" requests is done with that.

LiveData

https://developer.android.com/reference/android/arch/lifecycle/MediatorLiveData

You can use a MediatorLiveData and two Fuel to livedata calls to get a live data that responds when both are done.

RxJava

You can use the same interface as in Retrofit to merge two Fuel to Observable calls.

Coroutines

You can make a new suspending function that awaits two things:

fun suspend both(){
  ...deferredCallOne
  ...deferredCallTwo

  val resultOne = deferredOne.await()
  val resultTwo = deferredTwo.await()
  return ...
}

I welcome someone to actually write these out as examples, but "merging two requests", outside the scope of HTTP/2 is not in the scope of Fuel.

>All comments

Retrofit can actually not merge requests by itself. When using an extension, such as RxJava with retrofit, "merging" requests is done with that.

LiveData

https://developer.android.com/reference/android/arch/lifecycle/MediatorLiveData

You can use a MediatorLiveData and two Fuel to livedata calls to get a live data that responds when both are done.

RxJava

You can use the same interface as in Retrofit to merge two Fuel to Observable calls.

Coroutines

You can make a new suspending function that awaits two things:

fun suspend both(){
  ...deferredCallOne
  ...deferredCallTwo

  val resultOne = deferredOne.await()
  val resultTwo = deferredTwo.await()
  return ...
}

I welcome someone to actually write these out as examples, but "merging two requests", outside the scope of HTTP/2 is not in the scope of Fuel.

Was this page helpful?
0 / 5 - 0 ratings