Event-Driven Architecture framework to build reactive apps 💣 https://api.onyxframework.org/eda


Built with Crystal Travis CI build API docs Latest release

An Event-Driven Architecture framework to build reactive apps.

Supporters ❤️

Thanks to all my patrons, I can continue working on beautiful Open Source Software! 🙏

Lauri Jutila, Alexander Maslov, Dainel Vera

You can become a patron too in exchange of prioritized support and other perks

About 👋

Onyx::EDA is an Event-Driven Architecture framework. It allows to emit certain events and subscribe to them.

It has several channels implemented:

Installation 📥

Add this to your application's shard.yml:

    github: onyxframework/eda
    version: ~> 0.2.0

This shard follows Semantic Versioning v2.0.0, so check releases and change the version accordingly. Please visit github.com/crystal-lang/shards to know more about Crystal shards.

Usage 💻

First of all, you need to create a channel:

require "onyx-eda"
channel = Onyx::EDA::Channel.new

# or

require "onyx-eda"
require "onyx-eda/channel/redis"

channel = Onyx::EDA::Channel::Redis.new("redis://localhost:6379")

Then define events to emit:

struct MyEvent
  include Onyx::EDA::Event

  getter foo

  def initialize(@foo : String)

Subscribe an object to the event:

# Top-level subscription
channel.subscribe(Object, MyEvent) do |event|
  pp event.foo

# Object-level subscriptions

class Notifier
  def initialize(channel)
    channel.subscribe(self, MyEvent) do |event|
      pp event.foo

notifier = Notifier.new(channel)

Then emit the event:


All subscribers will asynchronously notified of the new event. You can then unsubscribe:


Using with Onyx top-level macros

Onyx shard has convenient macros to reduce boilerplate code. Once "onyx/eda" is required, a singleton Onyx.channel is defined. You can then specify which channel to use, for example, Onyx.channel(:redis).

require "onyx/eda"

struct MyEvent
  # ditto


Onyx.subscribe(Object, MyEvent) do |event|
  # ditto

# or



Community 🍪

There are multiple places to talk about this particular shard and about other ones as well:

Support ❤️

This shard is maintained by me, Vlad Faust, a passionate developer with years of programming and product experience. I love creating Open-Source and I want to be able to work full-time on Open-Source projects.

I will do my best to answer your questions in the free communication channels above, but if you want prioritized support, then please consider becoming my patron. Your issues will be labeled with your patronage status, and if you have a sponsor tier, then you and your team be able to communicate with me in private or semi-private channels such as e-mail and Twist. There are other perks to consider, so please, don't hesistate to check my Patreon page:

You could also help me a lot if you leave a star to this GitHub repository and spread the world about Crystal and Onyx! 📣


  1. Fork it ( https://github.com/onyxframework/eda/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'feat: some feature') using Angular style commits
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request



This software is licensed under MIT License.

Open Source Initiative

Github statistic:
  • 4
  • 0
  • 1
  • 5
  • 10 days ago


MIT License