Skip to content

Commit

Permalink
fix(media): check if subscription has been created before unsubscribi…
Browse files Browse the repository at this point in the history
…ng (#401)

there are cases when ngOnDestroy is executed before ngOnInit can even execute, so we need to validate for that.
  • Loading branch information
emoralesb05 authored and richavyas committed Mar 3, 2017
1 parent 9ce8469 commit 7b559d4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/platform/core/media/directives/media-toggle.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ export class TdMediaToggleDirective implements OnInit, OnDestroy {
}

ngOnDestroy(): void {
this._subscription.unsubscribe();
if (this._subscription) {
this._subscription.unsubscribe();
}
}

private _mediaChange(matches: boolean): void {
Expand Down

0 comments on commit 7b559d4

Please sign in to comment.