npm.io
0.0.22 • Published 3 years ago

supa-app

Licence
MIT
Version
0.0.22
Deps
0
Size
15 kB
Vulns
0
Weekly
0

supa-app

A Supa Small Reactive View Library

Install

npm i supa-app

Counter App Demo

import { h, text, runApp } from 'supa-app';

const IncrementBy = amt => state => ({ 
  ...state, count: state.count + amt 
});

runApp({
  node: document.getElementById('app'),
  state: {
    count: 0
  },
  effects: state => [],
  subscriptions: state => [],
  view: (state, setState) => {
    return (
      h('main', {}, 
        h('output', {}, 
          text('Counter: '), text(state.count)
        ),
        h('div', {},
          h('button', { onclick: () => setState(IncrementBy(1)) }, text('+')),
          h('button', { onclick: () => setState(IncrementBy(-1)) }, text('-'))
        )
      )
    )
  }
});