Skip to content

typedeventemitter 1.0.2

Install from the command line:
Learn more about npm packages
$ npm install @8128-33550336/typedeventemitter@1.0.2
Install via package.json:
"@8128-33550336/typedeventemitter": "1.0.2"

About this version

typedEventEmitter

publish

Package

Language: Japanese

About

This is EventEmiter typed with TypeScript

Install

~/.npmrc

@8128-33550336:registry=https://npm.pkg.github.com

//npm.pkg.github.com/:_authToken=YourTokenHere
$ npm i @8128-33550336/typedeventemitter

Example

Usage as Parent Class

class MyClass extends TypedEventEmitter<{
    foo: [value: string];
    bar: [];
    baz: [value: number];
}> {
    constructor() {
        super();
        this.on('baz', num => {
            this.emit('foo', num + '');
            this.emit('bar');
        });
    }
}

const myClass = new MyClass();

myClass.on('foo', value => {
    console.log('foo', value);
});

myClass.on('bar', () => {
    console.log('bar');
});

myClass.emit('baz', 42);

Simple usage

const myEventEmitter = new TypedEventEmitter();

myEventEmitter.on('baz', num => {
    myEventEmitter.emit('foo', num + '');
    myEventEmitter.emit('bar');
});

myEventEmitter.on('foo', value => {
    console.log('foo', value);
});

myEventEmitter.on('bar', () => {
    console.log('bar');
});

myEventEmitter.emit('baz', 42);

We welcome issues and pull requests.

Details


Assets

  • typedeventemitter-1.0.2.tgz

Download activity

  • Total downloads 1
  • Last 30 days 0
  • Last week 0
  • Today 0