TypeScript Signal
Signal Pattern pattern written in Typescript.
Signals are typed and easy to use!
Installation
npm install signal-ts
Usage
Creating a Signal
Create an instance of Signal with the specified type, i.e, string, number, etc.
; ;
Add function callback
Register a callback with add().
onCompleted.add;
You can also register a callback only once().
onCompleted.oncen: number );
Emitting a Signal
onCompleted.emit299792458;
Pro-Tips
Organize your events in a module or namespace.
Bind to events in your constructor.
Remove a callback
Event.onLoaded.removethis.callback;