Coder Social home page Coder Social logo

aero's Introduction

aerolith

Synopsis

Microframework for correlating events from observables

Stories

The core model is a Story object that describes the ongoing 'journey' of a domain model as events are processed

We route events to matching story methods, given the event correlates with the attributes that the story model specifies.

If we detect an event that is one of the event types that the story declares it startsWith... We'll use the event attributes this story declares it is correlatedOn... And route further correlated events to methods on this story.

So the story ends up looking something like a domain controller:

import { Story } from 'aerolith'
export class TestStory extends Story {
    name = 'test'
    correlatedOn = ['productId', 'specId', 'testId']
    startsWith = 'test:run-started'
    endsWith = 'test:run-completed'

    runStarted () {}

    runCompleted (e: RunCompleteEvent) {
      this.test.status = e.status
    }

    // ...
}

Setup

aero expects you to tell it which stories to play, and which observable it should monitor.

  const aero: Aero<TrialEvent> = new Aero(observable)
  const stories = [ProductStory, SpecStory, TestStory]
  aero.play(...stories)
  aero.observable.subscribe()

Configuration

Stories may specify a timeout which will throw an error if the observable doesn't complete the journey within the duration.

Notes

  • This solution means a lot of implicit structure is taken from the event name. The event name is expected to be of the form category:something-happened. We currently assume the "category" string appearing before the colon is an implicit namespace

    This "channel separation" exists primarily in order not to send redundant or inaccurate events, but a limitation is that we are currently limited to the single domain a story specifies (so a story couldn't monitor events across "domains" for now).

    One thought is that stories might specify the 'channels' they are interested in, but note this creates some ambiguity with the "controller-style" routing mechanism. That is: if two events in different domains happen to have the same name (i.e., are identical 'after the colon'), they would end up incorrectly invoking the same story action...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.