1
1
Fork
You've already forked FeatherChoo
0
A fork of nanochoo for Feather Wiki
  • JavaScript 100%
Find a file
2023年10月27日 22:40:12 -06:00
.gitignore Remove unneeded files 2023年10月27日 22:11:25 -06:00
.npmrc chore(pkg): banish lock file ( #568 ) 2017年09月20日 21:12:37 +02:00
CHANGELOG.md Upgrade dependencies; Update changelog 2022年10月25日 14:26:30 -06:00
index.js Strip out everything unnecessary 2023年10月27日 22:40:12 -06:00
LICENSE . 2016年05月11日 01:09:53 +07:00
package.json Strip out everything unnecessary 2023年10月27日 22:40:12 -06:00
README.md Strip out everything unnecessary 2023年10月27日 22:40:12 -06:00

nanochoo

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

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

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 events removed
    • nanorouter, scroll-to-anchor, nanolocation, nanoquery no longer dependencies
  • rename DOMCONTENTLOADED to ONLOAD, DOMTITLECHANGE to TITLE, and NAVIGATE to GO
  • replace choo.use and document-ready dependency with choo.ready function
  • choo.toString is removed

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.ready(() => countStore(app)); // instead of use!
app._view = mainView; // instead of route!
app.mount('body');
function mainView (state, emit) {
 return html`
 <body>
 <h1>count is ${state.count}</h1>
 <button onclick=${() => emit('increment', 1)}>increment!</button>
 </body>
 `;
}
function countStore (app) {
 const { state, emitter } = app;
 state.count = 0;
 emitter.on('increment', function (count) {
 state.count += count;
 emitter.emit('render');
 });
}

License

MIT. See choo