New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@valeera/eventfirer

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@valeera/eventfirer

Event dispatcher fit for most framework.

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
2
100%
Maintainers
1
Weekly downloads
 
Created
Source

EventDispatcher

A light library for creating custom events.

Install

npm i @valeera/eventdispatcher

or

yarn add @valeera/eventdispatcher

Basic usage

<script src="EventDispatcher.js"></script>
<script>

    class Car extends EventDispatcher {
        start = () => {
            this.dispatchEvent('car-a', {message: 'aaa'});
            this.dispatchEvent('car-b', {message: 'bbb'});
            this.dispatchEvent('car-c', {message: 'ccc'});
            this.dispatchEvent('bus-1', {message: '111'});
            this.dispatchEvent('bus-2', {message: '222'});
        };
    }

    const car = new Car();

    car.on('car-a', function (event) {
        console.log("on: ", event.target.message)
    }).filt((type) => {
        return type.indexOf('car') > -1;
    }, (event) => {
        console.log('filt: ', event.target.message);
    }).all((event) => {
        console.log('all: ', event.target.message);
    });

    car.start();

</script>

In broswer console, you could see:

on:  aaa
filt:  aaa
all:  aaa
filt:  bbb
all:  bbb
filt:  ccc
all:  ccc
all:  111
all:  222

Keywords

EventFirer

FAQs

Package last updated on 26 Nov 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