aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Miller <[email protected]>2020-07-15 14:40:59 +0000
committerJason Miller <[email protected]>2020-07-15 14:40:59 +0000
commit0f41ead697945b38d55435306a21068c04445863 (patch)
treea40295bf7bd467641b7b9edbc819563c636471ef /src
parent5116df46a020ae498eec6783cfe9147fc9add015 (diff)
parent76a353cb867a7302a9ddfb9a2a96ab5364af1db9 (diff)
Merge branch 'expose-all' of https://github.com/jaylinski/mitt
Diffstat (limited to 'src')
-rw-r--r--src/index.ts15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/index.ts b/src/index.ts
index c681fd0..ae85607 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -13,6 +13,8 @@ export type WildCardEventHandlerList = Array<WildcardHandler>;
export type EventHandlerMap = Map<EventType, EventHandlerList | WildCardEventHandlerList>;
export interface Emitter {
+ all: EventHandlerMap;
+
on<T = any>(type: EventType, handler: Handler<T>): void;
on(type: '*', handler: WildcardHandler): void;
@@ -23,9 +25,10 @@ export interface Emitter {
emit(type: '*', event?: any): void;
}
-/** Mitt: Tiny (~200b) functional event emitter / pubsub.
- * @name mitt
- * @returns {Mitt}
+/**
+ * Mitt: Tiny (~200b) functional event emitter / pubsub.
+ * @name mitt
+ * @returns {Mitt}
*/
export default function mitt(all?: EventHandlerMap): Emitter {
all = all || new Map();
@@ -33,6 +36,11 @@ export default function mitt(all?: EventHandlerMap): Emitter {
return {
/**
+ * A Map of event names to registered handler functions.
+ */
+ all,
+
+ /**
* Register an event handler for the given type.
* @param {string|symbol} type Type of event to listen for, or `"*"` for all events
* @param {Function} handler Function to call in response to given event
@@ -48,7 +56,6 @@ export default function mitt(all?: EventHandlerMap): Emitter {
/**
* Remove an event handler for the given type.
- *
* @param {string|symbol} type Type of event to unregister `handler` from, or `"*"`
* @param {Function} handler Handler function to remove
* @memberOf mitt