Is it necessary to unsubscribe from observables created by Http methods?

前端 未结 9 1678
醉酒成梦
醉酒成梦 2020-11-22 04:50

Do you need to unsubscribe from Angular 2 http calls to prevent memory leak?

 fetchFilm(index) {
        var sub = this._http.get(`http://example.com`)
              


        
9条回答
  •  -上瘾入骨i
    2020-11-22 05:00

    You shouldn't unsubscribe from observables that completes automatically (e.g Http, calls). But it's necessary to unsubscribe from infinite observables like Observable.timer().

提交回复
热议问题