Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/futantan/create-emit


https://github.com/futantan/create-emit

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

# create-emit

## Introduction

> Tiny 20 lines of functional type safe event emitter/pubsub.

Comparing to other emitters, `create-emit` cares more about type safe.

## Installation

```sh
npm install --save create-emit
# or
yarn add create-emit
```

## Usage
```typescript
// create event with `string` type of payload
const sayHi = createEmit()

// you can watch for the event to happen
const unsubscribe = sayHi.watch(console.log)

// fire the event with payload
sayHi('Peter') // Peter
sayHi('Drew') // Drew
```