All Projects → gelldur → Eventbus

gelldur / Eventbus

Licence: apache-2.0
A lightweight and very fast event bus / event framework for C++17

Programming Languages

cpp17
186 projects

Labels

Projects that are alternatives of or similar to Eventbus

Ticket Analysis
移动端的彩票开奖查询系统
Stars: ✭ 61 (-59.06%)
Mutual labels:  eventbus
Ts Event Bus
📨 Distributed messaging in TypeScript
Stars: ✭ 85 (-42.95%)
Mutual labels:  eventbus
Rxbus2
RxJava2 based bus with queuing (e.g. lifecycle based) support
Stars: ✭ 116 (-22.15%)
Mutual labels:  eventbus
Rxeventbus
A EventBus based on RxJava2, using Retention.CLASS annotation.
Stars: ✭ 68 (-54.36%)
Mutual labels:  eventbus
Resugan
simple, powerful and unobstrusive event driven architecture framework for ruby
Stars: ✭ 82 (-44.97%)
Mutual labels:  eventbus
Event
📢 Lightweight event manager and dispatcher implements by Go. Go实现的轻量级的事件管理、调度程序库, 支持设置监听器的优先级, 支持根据事件名称来进行一组事件的监听
Stars: ✭ 99 (-33.56%)
Mutual labels:  eventbus
Asombroso Ddd
Una lista cuidadosamente curada de recursos sobre Domain Driven Design, Eventos, Event Sourcing, Command Query Responsibility Segregation (CQRS).
Stars: ✭ 41 (-72.48%)
Mutual labels:  eventbus
Androideventbus
[DEPRECATED] A lightweight eventbus library for android, simplifies communication between Activities, Fragments, Threads, Services, etc.
Stars: ✭ 1,597 (+971.81%)
Mutual labels:  eventbus
Rabbitevents
Nuwber's events provide a simple observer implementation, allowing you to listen for various events that occur in your current and another application. For example, if you need to react to some event published from another API.
Stars: ✭ 84 (-43.62%)
Mutual labels:  eventbus
Cscore
cscore is a minimal-footprint library providing commonly used helpers & patterns for your C# projects. It can be used in both pure C# and Unity projects.
Stars: ✭ 115 (-22.82%)
Mutual labels:  eventbus
Videosniffer
视频嗅探服务(VideoSniffer API Service On Android)
Stars: ✭ 68 (-54.36%)
Mutual labels:  eventbus
Fluxxan
Fluxxan is an Android implementation of the Flux Architecture that combines concepts from both Fluxxor and Redux.
Stars: ✭ 80 (-46.31%)
Mutual labels:  eventbus
Kotlinmvpsamples
🚀(Kotlin 版 )快速搭建 Kotlin + MVP + RxJava + Retrofit + EventBus 的框架,方便快速开发新项目、减少开发成本。
Stars: ✭ 103 (-30.87%)
Mutual labels:  eventbus
Rhub
Reactive Event Hub
Stars: ✭ 66 (-55.7%)
Mutual labels:  eventbus
Milkomeda
Spring extend componets which build from experience of bussiness, let developers to develop with Spring Boot as fast as possible.(基于Spring生态打造的一系列来自业务上的快速开发模块集合。)
Stars: ✭ 117 (-21.48%)
Mutual labels:  eventbus
Rxemitter
RxEmitter = 🐟Rxjs + 🐡eventBus.
Stars: ✭ 43 (-71.14%)
Mutual labels:  eventbus
Rabbus
A tiny wrapper over amqp exchanges and queues 🚌 ✨
Stars: ✭ 86 (-42.28%)
Mutual labels:  eventbus
Router
Router —— A substitute good of EventBus similar implemented by dynamic proxy
Stars: ✭ 147 (-1.34%)
Mutual labels:  eventbus
Eventbus
C# 事件总线实现
Stars: ✭ 127 (-14.77%)
Mutual labels:  eventbus
Channel
一行代码发送和接收事件LiveData|LifeCycle|Coroutine特性的事件总线框架
Stars: ✭ 108 (-27.52%)
Mutual labels:  eventbus

EventBus GitHub version

  Build status for Travis   Build status for Appveyor

Simple and very fast event bus. The EventBus library is a convenient realization of the observer pattern. It works perfectly to supplement the implementation of MVC logic (model-view-controller) in event-driven UIs

General concept EventBus Diagram

EventBus was created because I want something easy to use and faster than CCNotificationCenter from cocos2d-x library. Of course C++11 support was mandatory at that moment.

EventBus main goals:

  • Fast
  • Easy to use
  • Strongly typed
  • Free
  • tiny (~37 KB)
  • Decouples notification senders and receivers
  • on every platform you need (cross-platform)

Brief @ presentation

Presentation google docs

Sample / use cases

You can checkout use_case/
If you want to play with sample online checkout this link: wandbox.org

Usage

  1. Store bus
// store it in controller / singleton / std::sharted_ptr whatever you want
auto bus = std::make_shared<EventBus>();
  1. Define events
namespace event // optional namespace
{
	struct Gold
	{
		int goldReceived = 0;
	};

	struct OK {}; // Simple event when user press "OK" button
}
  1. Subscribe
// ...
dexode::EventBus::Listener listener{bus};
listener.listen([](const event::Gold& event) // listen with lambda
                {
                     std::cout << "I received gold: " << event.goldReceived << " 💰" << std::endl;
                });

HudLayer* hudLayer;
// Hud layer will receive info about gold
hudLayer->listener.listen<event::Gold>(std::bind(&HudLayer::onGoldReceived, hudLayer, std::placeholders::_1));
  1. Spread the news
//Inform listeners about event
bus->postpone(event::Gold{12}); // 1 way
bus->postpone<event::Gold>({12}); // 2 way

event::Gold myGold{12};
bus->postpone(myGold); // 3 way

Checkout tests or use cases for more examples. Or create issue what isn't clear :)

Add to your project

EventBus can be added as ADD_SUBDIRECTORY to your cmake file. Then simply link it via TARGET_LINK_LIBRARIES Example:

# No tests/benchmarks target won't be added. Root CMakeLists is for development.
ADD_SUBDIRECTORY(path/to/EventBus/lib)
ADD_EXECUTABLE(MyExecutable
		main.cpp
		)

TARGET_LINK_LIBRARIES(MyExecutable PUBLIC Dexode::EventBus)

Also if you want you can install library and add it at any way you want. Eg.

mkdir -p lib/build/
cd lib/build
cmake -DCMAKE_BUILD_TYPE=Relase -DCMAKE_INSTALL_PREFIX=~/.local/ ..

cmake --build . --target install
# OR
make && make install

Now in Release/install library is placed.

Or, you can install the library through your package manager (dpkg, rpm, etc). E.g.

mkdir -p lib/build/
cd lib/build

# For most RH-based Distributions
cmake -DCMAKE_BUILD_TYPE=Relase -DCPACK_GENERATOR="RPM" ..

# For most Debian-based Distributions
cmake -DCMAKE_BUILD_TYPE=Relase -DCPACK_GENERATOR="DEB" ..

# Or for both of them
cmake -DCMAKE_BUILD_TYPE=Relase -DCPACK_GENERATOR="RPM;DEB" ..

cmake --build . --target package
# Or
make package

# For most Debian-based systems
sudo dpkg -i EventBus*.deb

# For most RH-based systems
sudo rpm -i EventBus*.rpm
# OR
sudo yum install EventBus*.rpm

Performance (could be outdated)

I have prepared some performance results. You can read about them here Small example:

check10NotificationsFor1kListeners                                     263 ns        263 ns    2668786 sum=-1.76281G
check10NotificationsFor1kListeners_CCNotificationCenter              11172 ns      11171 ns      62865 sum=54.023M

checkNotifyFor10kListenersWhenNoOneListens                              18 ns         18 ns   38976599 sum=0
checkNotifyFor10kListenersWhenNoOneListens_CCNotificationCenter     127388 ns     127378 ns       5460 sum=0

Issues ? GitHub issues

Please report here issue / question / whatever, there is chance 99% I will answer ;)

If you have any questions or want to chat use gitter.

Join the chat at https://gitter.im/EventBusCpp/Lobby

Tesing and metrics

// TODO

LoC Coverage Status

Thanks to GitHub contributors Open Source Helpers

For modern cmake refer

License

EventBus source code can be used according to the Apache License, Version 2.0. For more information see LICENSE file

If you don't like to read to much here is sumup about license Apache 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].