https://github.com/skrivle/tukio
Tukio is a minimal Pub-Sub implementation using class based events.
https://github.com/skrivle/tukio
event-emitter events javascript nodejs pubsub typescript
Last synced: about 1 month ago
JSON representation
Tukio is a minimal Pub-Sub implementation using class based events.
- Host: GitHub
- URL: https://github.com/skrivle/tukio
- Owner: skrivle
- License: mit
- Created: 2018-06-11T06:07:15.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-10T10:52:51.000Z (over 2 years ago)
- Last Synced: 2025-03-16T02:14:34.653Z (about 2 months ago)
- Topics: event-emitter, events, javascript, nodejs, pubsub, typescript
- Language: TypeScript
- Homepage:
- Size: 1.33 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Tukio
Tukio is a minimal Pub-Sub implementation using class based events.
## Why
Most of the javascript Pub-Sub implementations use string based events, which makes it impossible
for static type analysers like Typescript to infer the shape of an event inside an event handler. Tukio
resolves this by using class based events.## Installation:
```
npm install tukio --save
```## Usage:
```typescript
import EventBus from 'tukio';const eventBus = new EventBus();
class TodoNameUpdated {
name: string;
constructor(name: string) {
this.name = name;
}
}eventBus.subscribe(TodoNameUpdated, (event) => {
// Typescript can infer that event has a property name
console.log(event.name);
});eventBus.publish(new TodoNameUpdated('new name'));
```