npm

tessellation

1.2.0 • Public • Published

Library for Tessellation

npm install --save tessellation

createApp( reducer, initialState, [effect] )

renderEffect( ReactComponent, DomElement ): effect

import React from 'react'
import {createApp, renderEffect} from 'tessellation'
 
const reducer = (state, action) => {
  switch (action.type) {
    case 'ADD':
      return {
        ...state,
        value: state.value + 1
      }
 
    default:
      return reducer(state, action)
  }
}
 
const initialState = {value: 0}
 
const effects = [
  renderEffect(
    function View ({push, value}) {
      return <div>
        <span>{value}</span>
        <button onClick={() => push({type: 'ADD'})}>
          Add
        </button>
        <button onClick={() => push({type: 'REMOVE'})}>
          Remove
        </button>
      </div>
    },
    document.getElementById('root')
  ),
 
  () => (state) => console.log(state)
]
 
createApp(reducer, initialState, effects)

Package Sidebar

Install

npm i tessellation

Weekly Downloads

2

Version

1.2.0

License

ISC

Last publish

Collaborators

  • xaviervia