aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarin Ivanov <[email protected]>2019-04-27 09:57:55 +0300
committerMarin Ivanov <[email protected]>2019-04-27 10:01:33 +0300
commit1fc5ce993a1769a3d0dd5fe2fdb51726f06f804c (patch)
tree620dd3131d112503cf5eabae5c67e2c537b84166
parent43dcbd6f83647548464079e628297244145eb4f6 (diff)
Fix TypeScript warning and add caveats to ToC
-rw-r--r--README.md5
-rw-r--r--src/index.ts3
2 files changed, 5 insertions, 3 deletions
diff --git a/README.md b/README.md
index 84efa8e..b550b17 100644
--- a/README.md
+++ b/README.md
@@ -20,8 +20,9 @@
- [when](#when)
- [off](#off)
- [emit](#emit)
+ - [Caveats](#caveats)
- [Contribute](#contribute)
-- [Acknowledments](#acknowledments)
+ - [Acknowledments](#acknowledments)
- [License](#license)
## Install
@@ -130,7 +131,7 @@ Keep in mind, due to the nature, of the once handlers that self deregister, you
If you want to contribute, I would be happy to look in to your PRs.
-# Acknowledments
+## Acknowledments
I would like to thank [Jason Miller](https://jasonformat.com/) (@developit) for developing `mitt`. `nitt` is no more than just `mitt` with a few extras.
diff --git a/src/index.ts b/src/index.ts
index 3608ae1..722412b 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -37,10 +37,11 @@ export default function nitt(all: EventHandlerMap) {
* @param {Function} handler Function to call in response to given event
*/
once(type: string, handler: EventHandler) {
- const onceHandler = evt => {
+ const onceHandler = (evt: any) => {
handler(evt);
this.off(type, onceHandler);
};
+
this.on(type, onceHandler);
},