aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Khourshid <[email protected]>2018-09-19 08:36:23 -0400
committerJason Miller <[email protected]>2018-09-19 08:36:23 -0400
commit0f4e8f0d3c0cfe4581edd9e93d3dac0ce994eefb (patch)
treee4e8582b41b0cd78edd07af5255a3ada809b1386
parent820ac6a172efbbd472e0a802ffad6a882f0cbb27 (diff)
Fixing TypeScript usage. Fixes #60 (#67)
* Fixing TypeScript usage * Removing extraneous formatting
-rw-r--r--README.md6
-rw-r--r--mitt.d.ts14
2 files changed, 10 insertions, 10 deletions
diff --git a/README.md b/README.md
index 3625332..daa2924 100644
--- a/README.md
+++ b/README.md
@@ -57,7 +57,7 @@ You can find the library on `window.mitt`.
```js
import mitt from 'mitt'
-let emitter = mitt()
+const emitter = mitt()
// listen to an event
emitter.on('foo', e => console.log('foo', e) )
@@ -77,8 +77,8 @@ emitter.off('foo', onFoo) // unlisten
### Typescript
```ts
-import * as mitt from 'mitt';
-let emitter: mitt.Emitter = new mitt();
+import mitt from 'mitt';
+const emitter: mitt.Emitter = mitt();
```
## Examples & Demos
diff --git a/mitt.d.ts b/mitt.d.ts
index 41ea221..7b3121a 100644
--- a/mitt.d.ts
+++ b/mitt.d.ts
@@ -8,26 +8,26 @@ declare namespace mitt {
type Handler = (event?: any) => void;
interface MittStatic {
- new(all?: {[key: string]: Handler}): Emitter;
+ (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;
@@ -35,10 +35,10 @@ declare namespace mitt {
/**
* 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;