File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,7 @@ Register an event handler for the given type.
132132### off
133133
134134Remove an event handler for the given type.
135+ If omit the ` handler ` , all event handlers of the given type are deleted.
135136
136137#### Parameters
137138
Original file line number Diff line number Diff line change @@ -56,18 +56,20 @@ export default function mitt(all?: EventHandlerMap): Emitter {
5656
5757 /**
5858 * Remove an event handler for the given type.
59+ * If omit the `handler`, all event handlers of the given type are deleted.
5960 * @param {string|symbol } type Type of event to unregister `handler` from, or `"*"`
6061 * @param {Function } handler Handler function to remove
6162 * @memberOf mitt
6263 */
6364 off < T = any > ( type : EventType , handler ?: Handler < T > ) {
6465 const handlers = all . get ( type ) ;
6566 if ( handlers ) {
66- if ( handler ) {
67- handlers . splice ( handlers . indexOf ( handler ) >>> 0 , 1 ) ;
68- } else {
69- all . delete ( type ) ;
70- }
67+ if ( handler ) {
68+ handlers . splice ( handlers . indexOf ( handler ) >>> 0 , 1 ) ;
69+ }
70+ else {
71+ all . delete ( type ) ;
72+ }
7173 }
7274 } ,
7375
You can’t perform that action at this time.
0 commit comments