Project

low_event

0.0
The project is in a healthy, maintained state
Events and observers for event-driven applications
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Gem version

LowEvent

LowEvent is a framework for event-driven applications where events are present-tense, not past-tense.

Events

LowEvent represents events of all kinds; RequestEvent, RouteEvent, RenderEvent and ResponseEvent.

Inherit from LowEvent to create your own event:

class MyEvent < LowEvent
  def initialize(data:, action: :render)
    super(key: self.class, action:)
    @data = data
  end
end

Observers

Observe the event with:

class MyObserver
  include Observers
  observe MyEvent

  def render(event:)
    event.data
  end
end

Trigger the event's action on its observers with:

MyEvent.trigger(data: "Custom Data")

ℹ️ For more info see Observers.

Architecture

A LowEvent is primarily concerned with what is happening, not what has happened.

Comparison

An Event-Command Hybrid:

Event LowEvent Command
Tense Past Past/Present/Future Future
Naming OrderCreated OrderEvent CreateOrder
Action 🚫 :create_order
Mutability Immutable Mutable/Immutable Immutable
State Ordered Actions 🚫
Broadcasting One to many Ordered one to many One to one
Return value 🚫 Value or nil Value

Event Tree

LowEvent builds a tree of every event as it's occuring and every subsequent event that occurs because of that event:

Event Tree

Installation

Add gem 'low_event' to your Gemfile then:

bundle install