Socket
Book a DemoInstallSign in
Socket

@axtk/event-manager

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@axtk/event-manager

A lightweight event manager

3.0.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

npm browser node TypeScript

@axtk/event-manager

A lightweight event manager

Usage

Initialization:

import {EventManager} from '@axtk/event-manager';

let eventManager = new EventManager();

Adding a handler of a specific event type:

eventManager.addListener('task started', event => {
    console.log(event);
});

Of all events matching the pattern:

eventManager.addListener(/^task\s/, event => {
    console.log(event);
});

With captured parameters:

eventManager.addListener(/^(\S+)\s(?<status>.*)$/, event => {
    console.log(event.params[0], event.params.status);
});

Adding a handler of all events dispatched to the eventManager instance:

let listener = eventManager.addListener('*', event => {
    console.log(event);
});

Dispatching an event of a specific type and properties:

eventManager.dispatch('task started', {x: 42});

Removing a previously declared listener:

listener.remove();

Keywords

events

FAQs

Package last updated on 23 Jun 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.