Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pcrab/pevt
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/pcrab/pevt
- Owner: Pcrab
- License: mit
- Created: 2023-11-25T15:07:59.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-19T23:00:05.000Z (12 months ago)
- Last Synced: 2024-11-07T01:28:55.633Z (about 2 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).