Skip to content

Instantly share code, notes, and snippets.

@ajspeller
Created August 26, 2017 13:06
Show Gist options
  • Save ajspeller/a8355e51c7f2e2c791bc09cf357bdba1 to your computer and use it in GitHub Desktop.
Save ajspeller/a8355e51c7f2e2c791bc09cf357bdba1 to your computer and use it in GitHub Desktop.
Prevent memory leaves with Observables
private subscription;
cuisines;
constructor(private _af: AngularFire) {}
ngOnit() {
this.subscription = this._af
.database.list('cuisines')
.subscribe( () => {
this.cuisines = x;
console.log(this.cuisines);
});
}
ngOnDestroy() {
this.subscription.unsubscribe();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment