0.0.2 • Published 5 years ago

ts-elmish v0.0.2

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

ts-elmish

The Elm architecture for TypeScript.

A lightweight general purpose Elm-like runtime for TypeScript, based off of raj.

yarn add ts-elmish

Example

A counter that increments by one every thimne the user confirms.

import { Runtime } from '../src/ts-elmish'

new Runtime({
  init: [0],
  update: (message, state) => {
    return [state + 1]
  },
  view: (state, dispatch) => {
    const keepCounting = window.confirm(`Count is ${state}. Increment?`)
    if (keepCounting) {
      dispatch({})
    }
  }
})

Note: ts-elmish is view layer agnostic. Here we use the browser's built-in view to play the part.