A Node.js module that implement the observer pattern in react
npm install react-observer-pattern --save
import { Observer, IObserver } from 'react-observer-pattern';
export class test implements IObserver {
ReceiveNotification(message: any): void {
console.log(message);
}
constructor(){
Observer.GetGlobalInstance().RegisterObserver("key", this);
}
}
Observer.GetGlobalInstance().NotifyObservers("key", "message");
This sample show you :
- How to bind to a specific key
- How to send an information to a specific key