forked from bitgapp/eqMac
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource.component.ts
More file actions
39 lines (33 loc) · 1.03 KB
/
Copy pathsource.component.ts
File metadata and controls
39 lines (33 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { Component, OnDestroy, OnInit } from '@angular/core'
import { SourceChangedEventCallback, SourceService, SourceType } from './source.service'
@Component({
selector: 'eqm-source',
templateUrl: './source.component.html',
styleUrls: [ './source.component.scss' ]
})
export class SourceComponent implements OnInit, OnDestroy {
source: SourceType = 'File'
constructor (public sourceService: SourceService) { }
ngOnInit () {
this.setupEvents()
}
private onSourceChangedEventCallback: SourceChangedEventCallback
protected setupEvents () {
this.onSourceChangedEventCallback = ({ source }) => {
this.source = source
}
this.sourceService.onSourceChanged(this.onSourceChangedEventCallback)
}
private destroyEvents () {
this.sourceService.offSourceChanged(this.onSourceChangedEventCallback)
}
async setSource (source: SourceType) {
if (this.source !== source) {
this.source = source
this.sourceService.setSource(this.source)
}
}
ngOnDestroy () {
this.destroyEvents()
}
}