Skip to content

Commit

Permalink
💥 [Emitten] Improve listener argument typing (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
beefchimi authored Jan 30, 2023
1 parent 171b168 commit 591f16d
Show file tree
Hide file tree
Showing 8 changed files with 225 additions and 217 deletions.
6 changes: 6 additions & 0 deletions .changeset/flat-hairs-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'emitten': minor
---

- Prefer variadic listener arguments.
- Remove `.disposable()` method. Now returning the `dispose` function from `.on()`.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ Import and start emit’in!
```ts
import {Emitten} from 'emitten';

interface EventMap {
change: string;
count: number;
other: string[];
}
type EventMap = {
change(value: string): void;
count(value?: number): void;
collect(...values: boolean[]): void;
};

const myEmitter = new Emitten<EventMap>();

myEmitter.on('change', someFunction);
const dispose = myEmitter.on('change', (value) => {});
myEmitter.emit('change', 'Hello world');

dispose();
```

For more guidance, please take a look at the [`Examples document`](./docs/examples.md).
Loading

0 comments on commit 591f16d

Please sign in to comment.