developit / developit/mitt

Support for `.once()` API

Đang mở
#136 20 bình luận 48 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
TypeScript
Star
11.9k
Fork
488
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu từ entry point của TypeScript emitter và lần theo hành vi listener và emit hiện có được mô tả trong issue. Triển khai API `.once()` để handler `ready` chỉ chạy trong lần emit đầu tiên, sau đó xác minh rằng lần emit thứ hai không có tác động nào và hành vi listener hiện có vẫn không thay đổi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
typescript
Lĩnh vực
tooling
Loại issue
Tính năng
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.