Last active
September 2, 2018 17:23
-
-
Save pramoth/ebcd1c6022c3ed1584e494a82521f2ef to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import { Component, OnInit, OnDestroy } from '@angular/core'; | |
| import { MyServiceService } from '../my-service.service'; | |
| //import from gt-unsubscribe-on-detroy | |
| import { unsubscribeOnDetroy } from 'gt-unsubscribe-on-detroy'; | |
| @Component({ | |
| selector: 'app-b', | |
| templateUrl: './b.component.html', | |
| styleUrls: ['./b.component.css'] | |
| }) | |
| export class BComponent implements OnInit, OnDestroy { | |
| constructor(private singletonService: MyServiceService) { } | |
| ngOnInit() { | |
| //unsubscribeOnDetroy() accept only instance of OnDestroy | |
| this.singletonService.mySubject.pipe(unsubscribeOnDetroy(this)) | |
| .subscribe(); | |
| } | |
| ngOnDestroy(): void { | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment