Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/futantan/create-emit
https://github.com/futantan/create-emit
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/futantan/create-emit
- Owner: futantan
- License: mit
- Created: 2022-07-19T15:14:04.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-12T09:18:37.000Z (over 2 years ago)
- Last Synced: 2024-10-12T22:58:13.706Z (2 months ago)
- Language: TypeScript
- Size: 151 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
```