Skip to content

bare-bones virtual-dom starter using main-loop and browserify/watchify with npm run scripts

Notifications You must be signed in to change notification settings

sintaxi/virtual-dom-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

virtual-dom-starter

bare-bones virtual-dom starter using main-loop and browserify/watchify with npm run scripts

view the starter demo

quick start

$ npm run watch &
$ npm start

commands

  • npm run build - build js for production
  • npm run watch - automatically build js on file changes for development
  • npm start - start a development server

starter code

var h = require('virtual-dom/h')
var main = require('main-loop')
var loop = main({ n: 0 }, render, require('virtual-dom'))
document.querySelector('#content').appendChild(loop.target)

function render (state) {
  return h('div', [
    h('h1', 'clicked ' + state.n + ' times'),
    h('button', { onclick: onclick }, 'click me!')
  ])
  function onclick () {
    loop.update({ n: state.n + 1 })
  }
}

About

bare-bones virtual-dom starter using main-loop and browserify/watchify with npm run scripts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published