Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update index.ts #137

Closed
wants to merge 1 commit into from
Closed

Update index.ts #137

wants to merge 1 commit into from

Conversation

liymax
Copy link

@liymax liymax commented Jun 12, 2021

make the parameter "handler" of .off() be optional. when it is empty, clear all listener of this type

@@ -63,7 +63,12 @@ export default function mitt(all?: EventHandlerMap): Emitter {
off<T = any>(type: EventType, handler: Handler<T>) {
const handlers = all.get(type);
if (handlers) {
handlers.splice(handlers.indexOf(handler) >>> 0, 1);
if (!handler) {
handlers.splice(0, handlers.length);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
handlers.splice(0, handlers.length);
handlers.length = 0;

@developit
Copy link
Owner

This is a duplicate of #124 and #72.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants