We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
return new Observable((observer: Observer) => { this.http.get(this.getUserInfoUrl(CONTACT_URL)) .map(res => res.json().data) .subscribe(res=>{ observer.next(res); observer.complete(); }); });
The text was updated successfully, but these errors were encountered:
也就是说不要map,直接subscribe,也可以啊,大神这里面map的作用是
Sorry, something went wrong.
map 只是对数据的转换而已,当然也是可以把map里包含的操作全都放在 subscribe 里面处理,执行上没问题,但不太优雅而已。 所以推荐把数据转换或格式化等相关操作放到map,这样subscribe可以拿到纯净的数据了。
哦哦原来如此,谢谢老师
No branches or pull requests
return new Observable((observer: Observer) => {
this.http.get(this.getUserInfoUrl(CONTACT_URL))
.map(res => res.json().data)
.subscribe(res=>{
observer.next(res);
observer.complete();
});
});
The text was updated successfully, but these errors were encountered: