I know that it\'s good practice to unsubscribe from Observable to prevent memory leak.
But if it\'s Cold Observable
It is definitely the best practice to free the used memory in javascript just like other programming languages.
Since you are using angular 2 you can use ngOnDestroy life cycle hook to achieve as this method is executed when the component loses its scope.
Assuming that you use a below snippet to subscribe to a data
subscription = this._http.getMethod('...')
.subscribe(response => this.responses = response,
error =>this.errorMessage = error)
You should be using importing OnDestroy lifecycle hook from angular/core using an import statement.
import { OnDestroy } from '@angular/core'
implement OnDestroy in your component as
export class MyComponent implements onDestroy {
.............
ngOnDestroy() {
this.subscription.unsubscribe();
}
}