developit / developit/mitt

Support for `.once()` API

Aperta
#136 20 commenti 48 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
TypeScript
Stelle
11.9k
Fork
488
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

**Motivation**
I believe this is quite common use-case where you have to listen for an even only once (for example, module getting `ready`). The library does not support this inherently but could easily be done with some wiring. This would open up a new use-case support as well as users of the library does not have to write boilerplates on their own.

**Example Usage**
```ts
const emitter: mitt.Emitter = new mitt();

emitter.once('ready', () => console.log("Called Once");

emitter.emit('ready'); // Log: Called Once
emitter.emit('ready'); // No side effect
```

@developit I would love to know your opinion on this.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.