1.1.1 • Published 2 years ago

@rainbow-labs/rainbow-events v1.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Rainbow Events

Simple Typescript Event Emitter implementation

Example

import EventEmitter from '@rainbow-labs/rainbow-events';

class Person extends EventEmitter {

    private name : string;

    constructor(name : string) {
        super();

        this.name = name;
    }


    talk() : void {
        this.emit('talk', 'my', 'name', 'is', this.name);
    }
}


const Lina = new Person('Lina');

lina.on('talk', (...arguments) => {
    console.log(arguments.join(' '));
});

lina.talk();

lina.off('talk');
1.1.1

2 years ago