pattern1 [디자인 패턴] Observer pattern export interface Observer { update(): void; } export interface Observable { count: number; map: Record; addObserver(observer: Observer): number; removeObserver(id: number): void; notifyAll(): void; } export class Subject implements Observable { count: number = 0; public map: Record = {}; constructor() {} notifyAll(): void { for (const observer of Object.values(this.map)) { if (observer === undef.. 2023. 3. 5. 이전 1 다음