Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heapwolf/cxx-eventemitter
A minimalist event emitter for C++
https://github.com/heapwolf/cxx-eventemitter
event-emitter eventemitter
Last synced: 5 days ago
JSON representation
A minimalist event emitter for C++
- Host: GitHub
- URL: https://github.com/heapwolf/cxx-eventemitter
- Owner: heapwolf
- License: mit
- Created: 2014-06-03T01:30:59.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-04-13T13:12:48.000Z (over 5 years ago)
- Last Synced: 2024-11-01T18:42:18.982Z (12 days ago)
- Topics: event-emitter, eventemitter
- Language: C++
- Homepage:
- Size: 238 KB
- Stars: 33
- Watchers: 5
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SYNOPSIS
A minimalist event emitter for `C++`.# DESCRIPTION
This emitter allows you to emit and receive arbitrary/variadic paramaters of
equal type. Captures are also allowed.# EXAMPLE
```c++
#include "deps/datcxx/cxx-eventemitter/index.h"int main() {
EventEmitter ee;
ee.on("hello", [&](string name, int num) {
// ...do something with the values.
});ee.emit("hello", "beautiful", 100);
}
```# USAGE
This module is designed to work with the [`datcxx`][0] build tool. To add this
module to your project us the following command...```bash
build add datcxx/cxx-eventemitter
```# TEST
```bash
build run test
```# API
## INSTANCE METHODS
### `void` on(string eventName, lambda callback);
Listen for an event multiple times.### `void` once(string eventName, lambda callback);
Listen for an event once.### `void` emit(string eventName [, arg1 [, arg2...]]);
Emit data for a particular event.### `void` off(string eventName);
Remove listener for a particular event.### `void` off();
Remove all listeners on the emitter.### `int` listeners();
Number of listeners an emitter has.## INSTANCE MEMBERS
### maxListeners
Number of listeners an event emitter should have
before considering that there is a memory leak.[0]:https://github.com/datcxx/build