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 11// @flow
22// An event handler can take an optional event argument
33// and should not return a value
4- type EventHandler = ( typeOrEvent ? : string | any , event ? : any ) => void ;
4+ type EventHandler = ( event ? : any ) => void ;
5+ type WildCardEventHandler = ( type : string , event ? : any ) => void
6+
57// An array of all currently registered event handlers for a type
68type EventHandlerList = Array < EventHandler > ;
9+ type WildCardEventHandlerList = Array < WildCardEventHandler > ;
710// A map of event types and their corresponding event handlers.
811type EventHandlerMap = {
12+ '*' ?: WildCardEventHandlerList ,
913 [ type : string ] : EventHandlerList ,
1014} ;
1115
@@ -49,7 +53,7 @@ export default function mitt(all: EventHandlerMap) {
4953 * @param {Any } [evt] Any value (object is recommended and powerful), passed to each handler
5054 * @memberof mitt
5155 */
52- emit ( type : string , evt ? : any ) {
56+ emit ( type : string , evt : any ) {
5357 ( all [ type ] || [ ] ) . map ( ( handler ) => { handler ( evt ) ; } ) ;
5458 ( all [ '*' ] || [ ] ) . map ( ( handler ) => { handler ( type , evt ) ; } ) ;
5559 }
You can’t perform that action at this time.
0 commit comments