You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
997 B
35 lines
997 B
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.');
|
|
// }
|
|
// }
|
|
// }
|