Created
January 11, 2018 05:51
-
-
Save alvachien/eb9f99fac7fbbe4c15b67fc07bbbd568 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class myComponent { | |
private destroyed$: ReplaySubject<boolean> = new ReplaySubject(1); | |
constructor( | |
private serviceA: ServiceA, | |
private serviceB: ServiceB, | |
private serviceC: ServiceC) {} | |
ngOnInit() { | |
this.serviceA | |
.takeUntil(this.destroyed$) | |
.subscribe(...); | |
this.serviceB | |
.takeUntil(this.destroyed$) | |
.subscribe(...); | |
this.serviceC | |
.takeUntil(this.destroyed$) | |
.subscribe(...); | |
} | |
ngOnDestroy() { | |
this.destroyed$.next(true); | |
this.destroyed$.complete(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment