import { Subject } from "./Observable";
import { ObserverData } from "./ObserverData";

export interface Observer<T> {
    // Receive update from subject.
    update(data: ObserverData<T>): void;
}

// /**
//  * The Observer interface declares the update method, used by subjects.
//  */
// interface Observer {
//     // Receive update from subject.
//     update(subject: Subject): void;
// }

// /**
//  * Concrete Observers react to the updates issued by the Subject they had been
//  * attached to.
//  */
// class ConcreteObserverA implements Observer {
//     public update(subject: Subject): void {
//         if (subject.state < 3) {
//             console.log('ConcreteObserverA: Reacted to the event.');
//         }
//     }
// }

// class ConcreteObserverB implements Observer {
//     public update(subject: Subject): void {
//         if (subject.state === 0 || subject.state >= 2) {
//             console.log('ConcreteObserverB: Reacted to the event.');
//         }
//     }
// }