是否有必要从http方法创建的可观测数据中取消订阅?您需要取消订阅角2 http调用以防止内存泄漏吗? fetchFilm(index) {
var sub = this._http.get(`http://example.com`)
.map(result => result.json())
.map(json => {
dispatch(this.receiveFilm(json));
})
.subscribe(e=>sub.unsubscribe());
...
3 回答
红糖糍粑
TA贡献1815条经验 获得超6个赞
unsubscribeabort
// From the XHRConnection class
return () => {
_xhr.removeEventListener('load', onLoad);
_xhr.removeEventListener('error', onError);
_xhr.abort();
};unsubscribe
- 3 回答
- 0 关注
- 373 浏览
添加回答
举报
0/150
提交
取消
