No release in over 3 years
Low commit activity in last 3 years
Simple event bus. Easily emit and handle events.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.8
~> 0.60
 Project Readme

SimpleEventBus

Gem Version

Install

Gemfile:

gem 'simple-event-bus'

Shell:

gem install simple-event-bus

Usage

Use the SimpleEventBus class as a singleton, or instantiate new instances of it.

require 'event-bus'

SimpleEventBus.subscribe(:event_happened) do |params|
  puts "Event handled with block: #{params.inspect}"
end

class EventHandler
  def event_happened(params)
    puts "Event handled with method: #{params.inspect}"
  end
end

SimpleEventBus.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')