developit / developit/mitt

Support for `.once()` API

オープン
#136 コメント 20 件 リアクション 48 件 担当者 0 名 GitHub で見る
enhancement
主要言語
TypeScript
スター
11.9k
フォーク
488
PR マージ指標
30日以内にマージされた PR はありません

説明

**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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。