Sea for Elixir

Hex version badgeLicense badgeBuild status badgeCode coverage badge

Sea facilitates and abstracts away side-effects - an important aspect of your Elixir applications that often gets lost between the lines. It does so in a way loosely inspired by the observer pattern ie. by making the source event (here, represented by signal) aware of its listeners (here, represented by observers).

This design choice, as opposed eg. to pubsub where producer is made unaware of consumers, intentionally couples the signal with its observers in order to simplify the reasoning about synchronous operations within single system. It was introduced as an optimal abstraction for facilitating side-effect-like interactions between relatively uncoupled modules (or "contexts" if you will) that interact with each other in synchronous way within single coherent system.

Installation

Add sea to your list of dependencies in mix.exs:

def deps do
  [
    {:sea, "~> 0.3.0"}
  ]
end

You may pick the newest version number from Hex.

Usage

Complete documentation for Sea module, along with comprehensive guides that'll lead you through concepts behind Sea, can be found on HexDocs.

In addition to docs, you may also be interested in the invoicing_app sample application that implements a simple DDD project. There, Sea plays a key role in decoupling contexts that interact with each other within a single database transaction.

Motivation

Sea is a pattern library. As such it's really thin and technically unsophisticated (although it does take care of some little details so you don't have to). But the real benefits come from the pattern itself and its impact on your codebase.