-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added type definitions * Handler only has exactly one or no argument * Moved type defs to root folder
- Loading branch information
Showing
4 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
declare var mitt: mitt.MittStatic; | ||
|
||
declare module "mitt" { | ||
export = mitt; | ||
} | ||
|
||
declare namespace mitt { | ||
type Handler = (event?: any) => void; | ||
|
||
interface MittStatic { | ||
new(all?: {[key: string]: Handler}): Emitter; | ||
} | ||
|
||
interface Emitter { | ||
/** | ||
* Register an event handler for the given type. | ||
* | ||
* @param {string} type Type of event to listen for, or `"*"` for all events. | ||
* @param {Handler} handler Function to call in response to the given event. | ||
* | ||
* @memberOf Mitt | ||
*/ | ||
on(type: string, handler: Handler): void; | ||
|
||
/** | ||
* Function to call in response to the given event | ||
* | ||
* @param {string} type Type of event to unregister `handler` from, or `"*"` | ||
* @param {Handler} handler Handler function to remove. | ||
* | ||
* @memberOf Mitt | ||
*/ | ||
off(type: string, handler: Handler): void; | ||
|
||
/** | ||
* Invoke all handlers for the given type. | ||
* If present, `"*"` handlers are invoked prior to type-matched handlers. | ||
* | ||
* @param {string} type The event type to invoke | ||
* @param {any} [event] An event object, passed to each handler | ||
* | ||
* @memberOf Mitt | ||
*/ | ||
emit(type: string, event?: any): void; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "mitt", | ||
"main": "mitt.d.ts", | ||
"version": false | ||
} |