You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The docs state that the .off method accepts a star string to remove all event handlers:
type (string | symbol) Type of event to unregister handler from, or '*'
However, in my test, this does not work, and I can't understand how it could, since the source code is very simple and Map.get('*') will not return all handlers.
Is this a never-implemented feature and the docs are wrong?
The text was updated successfully, but these errors were encountered:
The docs are unclear here: .off('*') doesn't remove all listeners, it removes all wildcard (*) listeners:
constevents=mitt();// add two wildcard listeners:events.on('*',(type,e)=>console.log(type,e));letcount=0;functioncountEvents(type){count++;}events.on('*',countEvents);// Remove a specific wildcard listener:events.on('*',countEvents);// remove all wildcard listeners:events.off('*');
Mitt does not provide a way to remove all listeners by default. To add it, you can pass in a custom Map and clear it when necessary:
constall=newMap();constevents=mitt(all);events.on('foo',console.log);events.on('bar',console.info);all.clear();// remove all event listeners
The docs state that the
.off
method accepts a star string to remove all event handlers:However, in my test, this does not work, and I can't understand how it could, since the source code is very simple and Map.get('*') will not return all handlers.
Is this a never-implemented feature and the docs are wrong?
The text was updated successfully, but these errors were encountered: