Skip to content

Instantly share code, notes, and snippets.

@DevEarley
Last active October 3, 2018 17:01
Show Gist options
  • Save DevEarley/cc143c6c12668eb65fdadbff3dd4558b to your computer and use it in GitHub Desktop.
Save DevEarley/cc143c6c12668eb65fdadbff3dd4558b to your computer and use it in GitHub Desktop.
Best practice when using an observable...
this.titleService.emitterN$
.takeUntil(this.componentDestroyed$)
.subscribe(
(data: any) =>
{
// ... do something N
}
);
}
ngOnDestroy()
{
this.componentDestroyed$.next(true);
this.componentDestroyed$.complete();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment