我试图利用angular2中的可观测值,但我不明白为什么要用map()
比subscribe()
.
this.http.get('http://172.17.40.41:8089/api/Master/GetAllCountry')
现在使用subscribe(success, error, complete)
,我可以得到成功回调的所有值,并且可以返回完整回调的值.如果我能完成所有这些功能,那么map()
需要什么呢?这有什么好处吗?
In short, why one should write like this:
this.http.get('http://172.17.40.41:8089/api/Master/GetAllCountry')
.map(r=>{})
.subscribe(value => {
}, error => error, () => {
});
when they can simply write this without the map function:
this.http.get('http://172.17.40.41:8089/api/Master/GetAllCountry')
.subscribe(value => {
}, error => error, () => {
});