Skip to content

Commit

Permalink
Fixing TypeScript usage. Fixes developit#60 (developit#67)
Browse files Browse the repository at this point in the history
* Fixing TypeScript usage

* Removing extraneous formatting
  • Loading branch information
davidkpiano authored and developit committed Sep 19, 2018
1 parent 820ac6a commit 0f4e8f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) )
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions mitt.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@ 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;

/**
* 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;
Expand Down

0 comments on commit 0f4e8f0

Please sign in to comment.