Skip to content

A wrapper around choo API that allows to use choo components without a baked-in routing layer.

License

Notifications You must be signed in to change notification settings

graforlock/choo-detached

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

choo-detached

npm version

A wrapper around choo API that allows to use choo components without a baked-in routing layer.

JavaScript Style Guide

Example

var choo = require('choo-detached')
var html = require('choo-detached/html')
var log = require('choo-log')

var app = choo()
app.use(log())
app.use(countStore)
app.component(mainView)
app.mount('body')

function mainView (state, emit) {
  return html`
    <body>
      <h1>count is ${state.count}</h1>
      <button onclick=${onclick}>Increment</button>
    </body>
  `

  function onclick () {
    emit('increment', 1)
  }
}

function countStore (state, emitter) {
  state.count = 0
  emitter.on('increment', function (count) {
    state.count += count
    emitter.emit('render')
  })
}

About

A wrapper around choo API that allows to use choo components without a baked-in routing layer.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published