https://kotlinlang.org logo
Title
l

lawlorslaw

12/19/2018, 4:43 AM
so i have an api call that returns Single<List<Spot>>, i want to iterate through that list and make an api call for each spot in that list, then once i get the result of the second api call which will be a Single<List<Forecast> i want to operate on that list. how do i do that?
h

hmole

12/19/2018, 6:51 AM
fun apiCall(i: Int) = Single.just(i)

    Single
      .just(listOf(1))
      .toObservable()
      .flatMap { it.toObservable() }
      .flatMapSingle(::apiCall)
      .toList()
d

David

12/19/2018, 11:31 PM
Sounds like you are building a surfing app @lawlorslaw `Spot`s, `Tide`s,
Forecast
... all very familiar domain models to me. 😉
l

lawlorslaw

12/19/2018, 11:32 PM
Yep I am
d

David

12/19/2018, 11:32 PM
Is it in prod already? Link me.
It's in beta
Let me know what you think
d

David

12/19/2018, 11:36 PM
Sweet. Cheers. Will head on over. I would link you mine but alas my API has been down for about a month now 😑 ...my middleware is hosted on Openshift and they are in the middle of a "transition" to charging me bucket tonnes of 💰
l

lawlorslaw

12/20/2018, 8:36 AM
That's no fun
d

David

12/20/2018, 10:28 AM
Tell me about it. Saying I can't download in the UK? Feel free to send me an APK in a PM! #security.
l

lawlorslaw

12/20/2018, 10:33 AM
Oh sorry about that
i limited the distribution to the US since it only shows surf reports for beaches in California. its limited by the public api im using.
d

David

12/20/2018, 11:35 AM
no worries. If I had my API up and running I’d say you could use that to get coverage over the rest of the world! My API amalgamates data from NOAA, BoM, MetOffice (UK), WaveWatch III models, a XTide instance and WWO to get the swell, tide and weather for spots around the world. Been a labour of love (almost 7 years now since I started it!) …thinking of moving to GCP to avoid the price hikes of Openshift. It’s a free app, don’t want to haemorrhage cash.