An open API service indexing awesome lists of open source software.

https://github.com/coderyi/eventbus

A lightweight event bus for C++
https://github.com/coderyi/eventbus

Last synced: 10 months ago
JSON representation

A lightweight event bus for C++

Awesome Lists containing this project

README

          

EventBus是一种发布/订阅模式的框架,主要用于解耦。可以看一下[greenrobot](https://github.com/greenrobot/EventBus)的图



EventBus的优点是基本没有依赖关系,module间通信只需要知道事件名字就可以,是我个人比较推荐的。

示例

```
#include "EventBus.h"
#include

void foo(EventBus::BaseMessage *i)
{
EventBus::Message *j = static_cast*>(i);

std::cout<<*j->getData() << std::endl;
}

int main()
{
EventBus::Bus b;
b.addListener("hello", foo);
delete b.sendMessage(new EventBus::Message("hello", new std::string("Hello world !")));
return 0;
}

```