是否有必要從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 回答
Helenr
TA貢獻1780條經驗 獲得超4個贊
unsubscribeabort
// From the XHRConnection class
return () => {
_xhr.removeEventListener('load', onLoad);
_xhr.removeEventListener('error', onError);
_xhr.abort();
};unsubscribe
- 3 回答
- 0 關注
- 506 瀏覽
添加回答
舉報
0/150
提交
取消
