Add the power of Simple Events to your projects. Every event has an argument with its data.
npm install ste-simple-eventsargument with data when fired. If you use typescript, you can leverage the support for generics and get strongly typed code.Need a different type of event? Check out the others.



typescript
let clock = new Clock("Smu", 1000);//log the name of the clock and the tick argument to the console - this is an event
clock.onClockTick.subscribe((c, n) =>
console.log(
${c.name} ticked ${n} times.)
);
`$3
So let's look at the implementation from a TypeScript perspective. (Do you program NodeJs without typescript? Check this)`typescript
import { SimpleEventDispatcher } from "ste-simple-events";class Clock {
private _onSequenceTick = new SimpleEventDispatcher();
private _ticks: number = 0;
constructor(public name: string, timeout: number) {
setInterval(() => {
this._ticks += 1;
this._onSequenceTick.dispatch(this._ticks);
}, timeout);
}
public get onSequenceTick() {
return this._onSequenceTick.asEvent();
}
}
``Check the documentation or the examples for more information.
Need more info? Check the repo.