Request to Implement Unsubscribe Functionality in the Mitt Framework
- Dominant language
- TypeScript
- Stars
- 11.9k
- Forks
- 488
- PR merge metrics
- No merged PRs in 30d
Description
### Request to Implement Unsubscribe Functionality in the Mitt Framework
**Description:**
The current version of the Mitt framework lacks an `unsubscribe` feature, making it inconvenient to manage event listeners, especially when components are unmounted or no longer need to listen for events.
**Suggested Feature:**
Implement an `unsubscribe` method that allows users to easily remove specific event listeners.
**Example:**
```javascript
// Current usage in Mitt
const mitt = require('mitt');
const emitter = mitt();
const handler = () => console.log('Event triggered');
emitter.on('event', handler);
emitter.off('event', handler);
```
```javascript
// After adding the unsubscribe feature
const mitt = require('mitt');
const emitter = mitt();
// Proposed usage
const unsubscribe = emitter.on('event', () => console.log('Event triggered'));
unsubscribe(); // Now we can easily unsubscribe
```
**Conclusion:**
Adding the `unsubscribe` functionality would greatly improve the usability of the Mitt framework and align it with best practices in event handling. Thank you for considering this enhancement!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.