Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lucasliet/message-emitter
a simple event emitter with topic and subscriber to use internally in code for typescript
https://github.com/lucasliet/message-emitter
Last synced: about 18 hours ago
JSON representation
a simple event emitter with topic and subscriber to use internally in code for typescript
- Host: GitHub
- URL: https://github.com/lucasliet/message-emitter
- Owner: lucasliet
- License: mit
- Created: 2022-08-02T01:12:09.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-13T21:24:58.000Z (7 months ago)
- Last Synced: 2024-12-02T06:07:15.927Z (about 1 month ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/message-emitter
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Message Emitter
Execute functions estimulated by events.## installation
```SH
yarn add message-emitter
```## usage
```TS
import * as Emitter from 'message-emitter';Emitter.publish('test', 1, 2, 3 ,4 ); // pulish to topic 'test' the args 1, 2, 3, 4
Emitter.subscribe('test', args => console.log(args)); // if the topic was published execute callback function to given arguments
Emitter.deleteTopic('test'); // remove topic
Emitter.hasTopic('test'); // returns true if topic exists, otherwise false
```> ℹ for JavaScript <= es5 use require
```JS
var Emitter = require('message-emitter');
Emitter.publish('test', 1, 2, 3 ,4 );
```