File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export interface Emitter {
1818 on < T = any > ( type : EventType , handler : Handler < T > ) : void ;
1919 on ( type : '*' , handler : WildcardHandler ) : void ;
2020
21- off < T = any > ( type : EventType , handler : Handler < T > ) : void ;
21+ off < T = any > ( type : EventType , handler ? : Handler < T > ) : void ;
2222 off ( type : '*' , handler : WildcardHandler ) : void ;
2323
2424 emit < T = any > ( type : EventType , event ?: T ) : void ;
@@ -60,10 +60,14 @@ export default function mitt(all?: EventHandlerMap): Emitter {
6060 * @param {Function } handler Handler function to remove
6161 * @memberOf mitt
6262 */
63- off < T = any > ( type : EventType , handler : Handler < T > ) {
63+ off < T = any > ( type : EventType , handler ? : Handler < T > ) {
6464 const handlers = all . get ( type ) ;
6565 if ( handlers ) {
66+ if ( handler ) {
6667 handlers . splice ( handlers . indexOf ( handler ) >>> 0 , 1 ) ;
68+ } else {
69+ all . delete ( type ) ;
70+ }
6771 }
6872 } ,
6973
You can’t perform that action at this time.
0 commit comments