Skip to content

Instantly share code, notes, and snippets.

@stevermeister
Last active August 1, 2018 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevermeister/431d4e5e786a39d2a2cf46c1b2ab1d42 to your computer and use it in GitHub Desktop.
Save stevermeister/431d4e5e786a39d2a2cf46c1b2ab1d42 to your computer and use it in GitHub Desktop.
export class TestComponent {
constructor(private store: Store) { }
private componetDestroyed: Subject = new Subject();
todos: Subscription;
posts: Subscription;
ngOnInit() {
this.todosSubscription = this.store.select('todos').takeUntil(this.componetDestroyed).subscribe(console.log);
this.postsSubscription = this.store.select('posts').takeUntil(this.componetDestroyed).subscribe(console.log);
}
ngOnDestroy() {
this.componetDestroyed.next();
this.componetDestroyed.complete();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment