【发布时间】:2016-02-24 20:05:05
【问题描述】:
我有一个应用程序可以监控传感器的事件、转换它们并需要向订阅者推送上游。
例如,使用android.location.LocationManager 进行位置更改。转换可能包括使用原始lat/long 和GeoCoder 来获取Address。
如何为我的显示器 (LocationListener) 和发布者建模?
class MyLocationListener implements LocationListener {
void onLocationChanged(Location l) {
//Get Address using GeoCoder
}
}
class MetaAPI {
Observable<Address> address() {
return Observable.create({what}); //<-- What should I add here?
//Need to glue MyLocationManager and MetaAPI
}
}
//So that I can use like this -->
public AddressObservation {
void monitor() {
metaApi.address()
.subscribe(...)
...;
}
}
【问题讨论】:
标签: android rx-java reactive-programming rx-android