
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
event-dispatch
Advanced tools
Allows to register subscribers and dispatch events across the application.
Install module:
npm install event-dispatch --save
Use typings to install all required definition dependencies.
typings install
ES6 features are used, so you may want to install es6-shim too:
npm install es6-shim --save
if you are building nodejs app, you may want to require("es6-shim");
in your app.
or if you are building web app, you man want to add <script src="path-to-shim/es6-shim.js">
on your page.
Simply create a class and put annotations on its methods:
import {EventSubscriber, On} from "event-dispatch";
@EventSubscriber()
export class UserEventSubscriber {
@On("onUserCreate")
onUserCreate(user: User) {
console.log("User " + user.name + " created!");
}
@On("onStatusUpdate")
updateUserStatus(status: string) {
console.log("New status: " + status);
}
}
Then use EventDispatcher class to dispatch events:
import {EventDispatcher} from "event-dispatch";
// note that all your subscribers must be imported somewhere in the app, so they are getting registered
// on node you can also require the whole directory using [require all](https://www.npmjs.com/package/require-all) package
import "./subscriber/UserEventSubscriber";
let eventDispatcher = new EventDispatcher();
eventDispatcher.dispatch("onUserCreate", new User("Johny"));
eventDispatcher.dispatch("onStatusUpdate", "hello world");
Take a look on samples in ./sample for more examples of usages.
FAQs
Dispatching and listening for application events in Typescript
The npm package event-dispatch receives a total of 5,300 weekly downloads. As such, event-dispatch popularity was classified as popular.
We found that event-dispatch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.