-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathcomponent.ts
More file actions
23 lines (18 loc) · 605 Bytes
/
component.ts
File metadata and controls
23 lines (18 loc) · 605 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Each component stays synchronized through a mediator
import IComponent from './icomponent'
import Mediator from './mediator'
export default class Component implements IComponent {
#mediator: Mediator
#name: string
constructor(mediator: Mediator, name: string) {
this.#mediator = mediator
this.#name = name
}
notify(message: string): void {
console.log(this.#name + ': >>> Out >>> : ' + message)
this.#mediator.notify(message, this)
}
receive(message: string): void {
console.log(this.#name + ': <<< In <<< : ' + message)
}
}