https://github.com/mikhailvs/simple-event-bus
Simple event bus for Ruby
https://github.com/mikhailvs/simple-event-bus
emit-events event-bus publish-subscribe rails ruby
Last synced: 2 months ago
JSON representation
Simple event bus for Ruby
- Host: GitHub
- URL: https://github.com/mikhailvs/simple-event-bus
- Owner: mikhailvs
- License: mit
- Created: 2018-10-25T19:53:05.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2025-01-28T21:47:51.000Z (8 months ago)
- Last Synced: 2025-07-02T01:04:33.208Z (3 months ago)
- Topics: emit-events, event-bus, publish-subscribe, rails, ruby
- Language: Ruby
- Size: 17.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SimpleEventBus
[](https://badge.fury.io/rb/simple-event-bus)## Install
Gemfile:
```ruby
gem 'simple-event-bus'
```Shell:
```sh
gem install simple-event-bus
```## Usage
Use the `SimpleEventBus` class as a singleton, or instantiate new instances of it.```ruby
require 'event-bus'SimpleEventBus.subscribe(:event_happened) do |params|
puts "Event handled with block: #{params.inspect}"
endclass EventHandler
def event_happened(params)
puts "Event handled with method: #{params.inspect}"
end
endSimpleEventBus.emit(:event_happened, param1: 'hello', param2: 'world')
bus = SimpleEventBus.new
bus.subscribe(:event_happened, EventHandler.new, once: true)
bus.emit(:event_happened, request: 'handle THIS')
```