Skip to content

Latest commit

 

History

History
39 lines (22 loc) · 1.8 KB

README.md

File metadata and controls

39 lines (22 loc) · 1.8 KB

SAM-Redux (Live version)

This repo is an attempt to use Redux for SAM architecture while keeping time-travel possible. On the side, it introduces a way to handle actions with timeouts.

Also, it uses a very simple React component for the View.

Purpose

This repo intends to extend the discussion about SAM happening in Gitter.

Building

Clone the repo and run npm run watch to live edit the source or npm run build to build into /dist.

How it works

Actions

The View present()s values to the Model, which decides whether to accept them. Accepting means mutating the store with the received value. Redux is used for this mutation, allowing for Time-travel and Hot Reloading of the reducers.

nap (Next Action Predicate)

Runs after the Model has mutated (or not) and may dispatch automatic actions based on the State.

E.g. if (countingDown) { decreaseCounter() } (pseudocode)

State

In SAM, the State is a pure function of the Model (i.e. Store), and like React the View is a pure function of the State (that's why there is no V in SAM: State -> View).

SAM

SAM is State-Action-Model. It's a software architecture propsed by Jean-Jacques Dubray in his (in)famous article Why I no longer use MVC Frameworks / Part 2 and Introducing the SAM pattern as an alternative to MVC.

Dubray states that SAM is based on TLA+ concepts pioneered by Dr. Lamport.