0
Immutable.jsのobservableとMap構造を持つ同期メカニズムを実装しようとしています。Observableとして不変のマップ構造を使用する
Mapは観測可能にすることができないため、または私が間違った方法で行う可能性があります。
私はRxドキュメントを調べようとしましたが、ちょうど、戻り値、から、...のいずれもマップには適していないようです。
私が必要とするのは、自分がMapを購読コールバックに入れる前に(http.GETから取得した値で)待つことです。
import {List, Map} from 'immutable';
import {Observable} from 'rxjs/Observable';
...
processNewTopology(topology: List<Endpoint>): Observable<Map<string, any>> {
let ip: string = JSON.stringify(topology.get(0).ueIpAddress);
//this function is just a http GET that returns an osbervable string (imsi)
this.apiService.getImsiFromAAA(ip).subscribe(
imsi => myMap = this.reduceEndpointsToMap(imsi, topology),
error => this.errorMessage = <any>error
);
return myMap; // I need in some way to convert my map into an obervable
}
private reduceEndpointsToMap(imsi: string, topology: List<Endpoint>): Map<string, any> {
// this function take the imsi and a list point and build the map and return it
// the imsi is provided by http.GET
}
だから、別のクラスでは、私は地図を取得するためにprocessNewTopologyを呼び出します。 は、私が表示アクション
this.topologyService.processNewTopology(endpoints).subscribe(
myMap => {
// here I want to access the content of myMap to display the new topo
}
...
);
ありがとうございました!出来た。 – Charles