https://github.com/pcrab/pevt
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pcrab/pevt
- Owner: Pcrab
- License: mit
- Created: 2023-11-25T15:07:59.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-19T23:00:05.000Z (over 1 year ago)
- Last Synced: 2025-02-17T23:10:03.144Z (5 months ago)
- Language: TypeScript
- Size: 160 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PEvt
PEvt is a simple but type-safe eventbus library.
## Usage
```typescript
import createPEvt from "./index";// new pevt instance with msg name and msg value type defined explicitly.
const pevt = createPEvt<{
["some event"]: {
foo: string;
bar: boolean;
};
}>();// register event
pevt.on("some event", (msg: { foo: string; bar: boolean }) => {
console.log(msg);
});// emit event
pevt.emit("some event", {
foo: "some random string",
bar: true,
});
```More examples can be found in [test files](./src/index.spec.ts).