-
Notifications
You must be signed in to change notification settings - Fork 0
Observer
Alexandre Moreau-Lemay edited this page Aug 22, 2022
·
2 revisions
Template to create a new observer.
interface Observer<T> {
update(subject: Store<T>): void;
}The Store will trigger the method update when Store.set() or Store.notify() are triggered.
update(subject: Store<T>): void;-
subject: Store<T>The
Storethe observer is attached to.
class ConcreteObserver implements Observer<number> {
public update(subject: Store<number>) {
console.log(subject.state);
}
}