forked from developit/mitt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mitt.d.ts
46 lines (40 loc) · 1.12 KB
/
mitt.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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;
}
}