Skip to content

bates64/nanochoo

This branch is 29 commits ahead of, 63 commits behind choojs/choo:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Sep 7, 2018
d09cbbe · Sep 7, 2018
Jul 4, 2016
Sep 4, 2018
Aug 25, 2018
Nov 24, 2017
Sep 20, 2017
Oct 3, 2017
Jun 29, 2017
May 10, 2016
Aug 25, 2018
Jan 8, 2018
Dec 13, 2017
Sep 7, 2018
Aug 25, 2018

Repository files navigation

nanochoo

½🚂🚋🚋🚋🚋
choo but half the size
A 2kb framework for creating sturdy frontend applications on a diet

Fork of choo. Built with ❤︎ by Yoshua Wuyts and contributors

with npm

> npm install nanochoo

with <script>

<script src='//unpkg.com/nanochoo/dist/bundle.min.js'></script>

Major and minor version numbers equate to choo's: choo@^7.0 == nanochoo@^7.0. Patch numbers don't!

Key differences

  • choo/html removed - use nanohtml (npm install nanohtml) directly
  • Removed router:
    • choo() no longer takes an opts argument
    • choo.route(location, handler) replaced by choo.view(handler)
    • pushState, popState, replaceState, navigate events removed
    • nanorouter, nanohref, scroll-to-anchor, nanolocation no longer dependencies
  • document-ready no longer a dependency
  • choo.toString not exported in the browser

See choo for documentation - just ignore routing-related things, use choo.view over choo.route, and you'll be fine.

Example

var html = require('nanohtml')
var choo = require('nanochoo')

var app = choo()
app.use(countStore)
app.view(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')
  })
}

License

MIT. See choo

About

½:steam_locomotive: choo but 2kb

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%