Last active
February 9, 2020 03:24
-
-
Save IntegerMan/384d197b0ad0236e2c45a79517e9e8d5 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
import {Component, Input, OnDestroy, OnInit} from '@angular/core'; | |
import {Subscription} from 'rxjs'; | |
import {StoryEntry} from '../../Model/StoryEntry'; | |
import {StoryEntryType} from '../../Model/StoryEntryType'; | |
import {StoryService} from '../story.service'; | |
@Component({ | |
selector: 'app-story-view', | |
templateUrl: './story-view.component.html', | |
styleUrls: ['./story-view.component.scss'] | |
}) | |
export class StoryViewComponent implements OnInit, OnDestroy { | |
@Input() | |
public Entries: StoryEntry[] = []; | |
private entrySub: Subscription; | |
constructor(private storyService: StoryService) { | |
// Initial entries to the Entries collection are set here, but omitted for this sample | |
} | |
ngOnInit() { | |
this.entrySub = this.storyService.EntryAdded.subscribe(entry => this.Entries.push(entry)); | |
} | |
ngOnDestroy() { | |
if (this.entrySub) { | |
this.entrySub.unsubscribe(); | |
this.entrySub = null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment