https://github.com/alfredosalzillo/mett
A boring event emitter library
https://github.com/alfredosalzillo/mett
Last synced: 3 months ago
JSON representation
A boring event emitter library
- Host: GitHub
- URL: https://github.com/alfredosalzillo/mett
- Owner: alfredosalzillo
- Created: 2023-04-09T12:20:35.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-09T13:29:31.000Z (over 2 years ago)
- Last Synced: 2025-06-24T16:50:17.669Z (4 months ago)
- Language: TypeScript
- Size: 92.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# meet (boring-event-emitter)
[](https://github.com/alfredosalzillo/mett/actions/workflows/CD.yml)
[](https://github.com/alfredosalzillo/mett/actions/workflows/CI.yml)
[](https://codecov.io/gh/alfredosalzillo/mett)
[](https://badge.fury.io/js/boring-event-emitter)
[](https://github.com/semantic-release/semantic-release)A boring typed event emitter library.
## Install
This project uses node and npm. Go check them out if you don't have them locally installed.
```bash
npm install --save mett
# or
yarn add mett
```## Usage
```typescript
// using ES6 modules
import mett from 'boring-event-emitter'// using CommonJS modules
const mett = require('boring-event-emitter')
```Create a single-event event emitter.
```typescript
import mett from 'boring-event-emitter'// create a new event with numeric values
const event = mett()// listen to an event
const dispose = event.listen((value) => console.log(`value is ${value}`))// dispose a listener
dispose()// emit a value
event.emit(1)// read the last emitted value
const currentValue = event.lastEmittedValue
```### Options
`mett` accept the following options:
- `initialValue` the initialValue of the event emitter. Will be emitted on the listen if `replayLast` is `true`.
- `replayLast` emit to newly added listener the `lastEmittedValue`.