https://github.com/cjhdev/small_event
simple in-memory publish-subscribe
https://github.com/cjhdev/small_event
no-annoying-mixins publish-subscribe ruby simple
Last synced: 10 months ago
JSON representation
simple in-memory publish-subscribe
- Host: GitHub
- URL: https://github.com/cjhdev/small_event
- Owner: cjhdev
- License: mit
- Created: 2019-08-16T11:06:10.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-16T11:07:38.000Z (over 6 years ago)
- Last Synced: 2025-06-20T09:45:23.488Z (10 months ago)
- Topics: no-annoying-mixins, publish-subscribe, ruby, simple
- Language: Ruby
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
SmallEvent
==========
An in-memory publish/subscribe implementation for small-ish applications.
## Example
~~~ ruby
require 'small_event'
broker = SmallEvent::Broker.new
# consumer of all topics
broker.subscribe do |msg, topic|
puts "all got '#{msg}' from topic '#{topic}'"
end
# consumer of specific topic
broker.subscribe 'specific' do |msg, topic, sub|
puts "specific got '#{msg}' from topic '#{topic}'"
end
# consumer of matching topic
broker.subscribe(/event[0-9]+/) do |msg, topic, sub|
puts "matching got '#{msg}' from topic '#{topic}'"
end
# publish...
broker.publish "for all"
broker.publish "for specific", "specific"
broker.publish "for matching", "event1"
broker.publish "for matching", "event2"
broker.publish "not for matching", "event"
~~~
## License
SmallEvent has an MIT license.