Skip to content

Simple typescript event emitter, provides clean utilities to fire and listen to events.

Notifications You must be signed in to change notification settings

tejasupmanyu/tu-emitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

tu-emitter is a small, simple, typescript event emitter which provides clean utilities to fire and listen to events.

Usage

Inside your React project, add tu-emitter using,

yarn add tu-emitter

or with npm:

npm install tu-emitter

Quick Start

import { Emitter } from "tu-emitter";

const emitter = new Emitter();
emitter.addListener("event", function (x) {
  console.log(`event fired with args ${x}`);
});
emitter.fire("event", [5]); // Listener prints "event fired with args 5".

addListener() returns a subscription object, upon which remove can be called.

let subscription = emitter.addListener("event", listener);
subscription.remove();

License

The MIT License.

About

Simple typescript event emitter, provides clean utilities to fire and listen to events.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published