A fork of nanochoo for Feather Wiki
- JavaScript 100%
|
|
||
|---|---|---|
| .gitignore | Remove unneeded files | |
| .npmrc | chore(pkg): banish lock file ( #568 ) | |
| CHANGELOG.md | Upgrade dependencies; Update changelog | |
| index.js | Strip out everything unnecessary | |
| LICENSE | . | |
| package.json | Strip out everything unnecessary | |
| README.md | Strip out everything unnecessary | |
nanochoo
1⁄2🚂🚋🚋🚋🚋
choo but half the size
A
2kb framework for creating sturdy frontend applications on a diet
Key differences
choo/htmlremoved - use nanohtml (npm install nanohtml) directly- Removed router:
choo()no longer takes anoptsargumentchoo.route(location, handler)replaced bychoo._view = handlerpushState,popState,replaceStateevents removed- nanorouter, scroll-to-anchor, nanolocation, nanoquery no longer dependencies
- rename
DOMCONTENTLOADEDtoONLOAD,DOMTITLECHANGEtoTITLE, andNAVIGATEtoGO - replace
choo.useand document-ready dependency withchoo.readyfunction choo.toStringis 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');
});
}