{"id":49353758,"url":"https://github.com/leventkaragol/libcpp-event-hub","last_synced_at":"2026-04-27T11:32:12.611Z","repository":{"id":241165366,"uuid":"804173699","full_name":"leventkaragol/libcpp-event-hub","owner":"leventkaragol","description":"Thread-safe generic event library for C++ (17+)","archived":false,"fork":false,"pushed_at":"2025-03-17T06:06:13.000Z","size":15,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-17T00:37:35.003Z","etag":null,"topics":["event-driven","event-emitter","event-hub","event-listener","event-management","event-system","events","header-only","thread-safe"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leventkaragol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-22T05:10:38.000Z","updated_at":"2025-03-17T05:59:29.000Z","dependencies_parsed_at":"2024-05-22T19:55:50.741Z","dependency_job_id":null,"html_url":"https://github.com/leventkaragol/libcpp-event-hub","commit_stats":null,"previous_names":["leventkaragol/libcpp-event-hub"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leventkaragol/libcpp-event-hub","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leventkaragol%2Flibcpp-event-hub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leventkaragol%2Flibcpp-event-hub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leventkaragol%2Flibcpp-event-hub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leventkaragol%2Flibcpp-event-hub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leventkaragol","download_url":"https://codeload.github.com/leventkaragol/libcpp-event-hub/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leventkaragol%2Flibcpp-event-hub/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32335296,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["event-driven","event-emitter","event-hub","event-listener","event-management","event-system","events","header-only","thread-safe"],"created_at":"2026-04-27T11:32:11.707Z","updated_at":"2026-04-27T11:32:12.602Z","avatar_url":"https://github.com/leventkaragol.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libcpp-event-hub\n\nThread-safe generic event library for C++ (17+)\n\n[![linux](https://github.com/leventkaragol/libcpp-event-hub/actions/workflows/linux.yml/badge.svg)](https://github.com/leventkaragol/libcpp-event-hub/actions/workflows/linux.yml)\n[![windows](https://github.com/leventkaragol/libcpp-event-hub/actions/workflows/windows.yml/badge.svg)](https://github.com/leventkaragol/libcpp-event-hub/actions/workflows/windows.yml)\n\n\u003e [!TIP]\n\u003e Please read this document before using the library. I know, you don't have time but reading\n\u003e this document will save you time. I mean just this file, it's not long at all. Trial and error\n\u003e will cost you more time.\n\n# Table of Contents\n\n* [What is this library used for?](#what-is-this-library-used-for)\n* [How to add it to my project](#how-to-add-it-to-my-project)\n* [How to use?](#how-to-use)\n* [Semantic Versioning](#semantic-versioning)\n* [License](#license)\n* [Contact](#contact)\n\n## What is this library used for?\n\nC++ standard library does not include a ready to use Event Handling mechanism. This library is designed to work as a \nsingleton throughout the application and to communicate thread-safely between different code blocks via the required \nevents with its generic structure.\n\nWith the Event Hub library, you can add or remove new listeners to the events, as you are used to in other languages, \nlisten to a single event or all events from one place and emit them with the required type of data.\n\n\n## How to add it to my project?\n\nThis is a header only library with no external dependency. So actually, all you need is to add the libcpp-event-hub.hpp file\nin src folder to your project and start using it with #include.\n\nYou can find usage examples in the examples folder, also find a sample CMakeLists.txt file content below.\n\n```cmake\ncmake_minimum_required(VERSION 3.14)\n\nproject(myProject)\n\nadd_executable(myProject main.cpp libcpp-event-hub.hpp)\n\n```\n\n## How to use?\n\nYou can find a simple example of adding \u0026 deleting event listeners and emitting events to handle different types of them below.\n\n```cpp\n#include \"libcpp-event-hub.hpp\"\n#include \u003cstring\u003e\n#include \u003ciostream\u003e\n\nusing namespace lklibs;\n\nint main()\n{\n    // Get the singleton instance of the EventHub\n    auto\u0026 eventHub = EventHub::getInstance();\n\n    // Add a listener for testEvent1, which sends a string value\n    auto listener1Id = eventHub.addListener\u003cstd::string\u003e(\"testEvent1\", [](const std::string\u0026 eventName, const std::string\u0026 sender, const std::string\u0026 data)\n    {\n        std::cout \u003c\u003c \"1. listener received, Event name: \" \u003c\u003c eventName \u003c\u003c \", sender: \" \u003c\u003c sender \u003c\u003c \", data: \" \u003c\u003c data \u003c\u003c std::endl;\n    });\n\n    // Add a listener for testEvent2, which sends an int value\n    auto listener2Id = eventHub.addListener\u003cint\u003e(\"testEvent2\", [](const std::string\u0026 eventName, const std::string\u0026 sender, const int\u0026 data)\n    {\n        std::cout \u003c\u003c \"2 listener received, Event name: \" \u003c\u003c eventName \u003c\u003c \", sender: \" \u003c\u003c sender \u003c\u003c \", data: \" \u003c\u003c data \u003c\u003c std::endl;\n    });\n\n    // Add a general listener for all events with a string value\n    auto listener3Id = eventHub.addListener\u003cstd::string\u003e(\"*\", [](const std::string\u0026 eventName, const std::string\u0026 sender, const std::string\u0026 data)\n    {\n        std::cout \u003c\u003c \"General listener received: \" \u003c\u003c eventName \u003c\u003c \", sender: \" \u003c\u003c sender \u003c\u003c \", data: \" \u003c\u003c data \u003c\u003c std::endl;\n    });\n\n    // Emit testEvent1 with a string value, 2 listeners will receive the event (listener1 and the general listener)\n    eventHub.emit(\"testEvent1\", \"main\", std::string(\"Value 1\"));\n\n    // Emit testEvent2 with an int value, 1 listeners will receive the event (listener2), because there is no general listener for int values\n    eventHub.emit(\"testEvent2\", \"main\", 7);\n\n    // Remove the first listener for testEvent1\n    eventHub.removeListener(\"testEvent1\", listener1Id);\n\n    // Emit testEvent1 again, only the general listener will receive the event\n    eventHub.emit(\"testEvent1\", \"main\", std::string(\"Value 2\"));\n\n    return 0;\n}\n```\n\n## Semantic Versioning\n\nVersioning of the library is done using conventional semantic versioning. Accordingly,\nin the versioning made as **MAJOR.MINOR.PATCH**;\n\n**PATCH:** Includes possible Bug\u0026Fixes and improvements. You definitely want to get this.\n\n**MINOR:** Additional functionality added via backwards compatibility. You probably want to\nget this, it doesn't hurt.\n\n**MAJOR:** Additional functionality that breaks backwards compatibility. You'll need to know\nwhat's changed before you get it, and you'll probably have to make changes to your own code.\nIf I publish something like this, I will definitely add the changes required for migration\nsection to the documentation.\n\n## License\n\nMIT License\n\nCopyright (c) 2024 Levent KARAGÖL\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n## Contact\n\nIf you have problems regarding the library, please open an\n[issue on GitHub](https://github.com/leventkaragol/libcpp-event-hub/issues/new).\nPlease describe your request, issue, or question in as much detail as possible\nand also include the version of your compiler and operating system, as well as\nthe version of the library you are using. Before opening a new issue, please\nconfirm that the topic is not already exists in closed issues.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleventkaragol%2Flibcpp-event-hub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleventkaragol%2Flibcpp-event-hub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleventkaragol%2Flibcpp-event-hub/lists"}