SAM Samples

March 28, 2026 · View on GitHub

SAM (State-Action-Model) is a reactive functional pattern that simplifies front-end and back-end architecture by clearly separating business logic from the view. All samples use the local sam-pattern library build.

Running Samples

Serve from the sam/ workspace root so that relative paths to ../../sam-lib/dist/SAM.js resolve correctly:

npx http-server -p 3000 .
# then open http://localhost:3000

http://localhost:3000 loads an index page with links to all samples below. Samples marked build required need npm install (and npm start / ng serve) run inside their directory.


TodoMVC

Full TodoMVC implementations across multiple frameworks:

SampleFrameworkNotes
todomvc-appVanilla JSReference implementation
todomvc-app-lit-htmllit-htmlnpm install required
todomvc-app-vueVue 2.6 + Vue Routernpm install required
todomvc-app-angularAngular 7npm install && ng serve
todomvc-app-reactReact 18 CRAnpm install && npm start

Vanilla JS

SampleDescription
vanilla-child-instanceParent/child SAM instance relationship
vanilla-focus-fieldsForm focus management with timesheet
vanilla-api-callsAsync API calls (requires external server)

React (CDN — no build needed)

SampleDescription
react-counterMinimal click counter with React 15 + JSX
react-child-instanceMulti-step form with parent/child SAM instance
react-sam-providerReact 18 Context Provider wrapping a SAM instance — npm install && npm start

Alternative Renderers

SampleDescription
inferno-rocketRocket launcher with Inferno vdom
lighterhtmllighterhtml renderer + sam-pattern

Server-Side (Node.js)

SampleDescriptionStart command
crud-blogExpress CRUD blognpm startlocalhost:5425/html/blog.html
server-side-timetravel-storeExpress + in-memory time-travel snapshot storenpm start

Tests

Puppeteer smoke tests cover all browser-based samples above:

cd tests
npm install
node samples.test.js

Change Log

  • 2026-03-27 Removed hash-dom from active samples (not fixable for Puppeteer testing)
  • 2026-03-27 Fixed todomvc-app-vue <base href> so scripts resolve correctly under http-server
  • 2026-03-27 Fixed inferno-rocket absolute script paths (/inferno.min.jsinferno.min.js)
  • 2026-03-27 Fixed vanilla-child-instance this-binding bugs in object literal methods
  • 2026-03-27 Fixed vanilla-focus-fields cmodel.urrentIndex typo
  • 2026-03-27 Added Puppeteer smoke test suite covering all active browser samples
  • 2026-03-27 Added sam/index.html launcher page with correct /sam-samples/... paths
  • 2026-03-27 Ran npm install for todomvc-app-lit-html and todomvc-app-vue
  • 2026-03-27 Polished READMEs for sam-lib, sam-fsm, and sam-samples
  • 2026-03-27 Replaced all CDN and npm sam-pattern references with the local sam-lib build
  • 2026-03-27 Upgraded todomvc-app-react from React 16 to React 18 (createRoot API)
  • 2026-03-27 Removed obsolete samples: Angular 2, Angular 4, AWS Alexa, Svelte