【发布时间】:2018-09-10 10:39:42
【问题描述】:
我正在寻找一个具有简洁架构方法的示例项目,但我在将单个项目转换为另一个项目时遇到了一些困难。
我有我的改装服务(单人):
@GET("nearbysearch/json") fun getNearbyPlaces(@Query("type") type: String, @Query("location") location: String, @Query("radius") radius: Int): Single<GooglePlacesNearbySearchResult>
我在我的存储库实现中使用它:
override fun getNearbyPlaces(type: String, location: String, radius: Int): Single<List<Place>> {
return googlePlacesApi.getNearbyPlaces(type, location, radius)
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.computation())
.doOnSuccess { googlePlacesNearbySearchResult -> nearbyPlaceListResultMapper.transform(googlePlacesNearbySearchResult) }
}
在这首单曲中,我想将我的Single<GooglePlacesNearbyResultSearch> 转换为Single<List<Place>>,并且我想用我的映射器NearbyPlaceListResultMapper 来做到这一点
问题是我最后没有成功获得Single<List<Place>>。我可以将其转换为 Observable 或 Completable 但不能转换为 Single。
谁能帮助我以更清洁的方式拥有它?
谢谢
【问题讨论】:
标签: rx-java retrofit2 reactivex clean-architecture rx-kotlin