made with esnextbin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const choo = require('choo') | |
const connect = require('throw-down/connect') | |
// Sample log functions | |
const constructed = (node) => console.log('constructed', node) | |
const added = (node) => console.log('added', node) | |
const mutated = (node) => console.log('mutated', node) | |
const removed = (node) => console.log('removed', node) | |
const app = choo() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var html = require('bel') | |
var text = html('<p>Some text</p>') | |
var el = html`<div>${text}</div>` | |
document.body.appendChild(el) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const knex = require('knex')({}) | |
console.log('accessing table') | |
knex.schema.table('users', function (table) { | |
console.log('inside') // this is never called | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const choo = require('choo') | |
const html = choo.view | |
const onload = require('on-load') | |
const app = choo() | |
const sampleData = { | |
authors: [ | |
{ name: 'George' }, | |
{ name: 'John' }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const choo = require('choo') | |
const html = choo.view | |
const onload = require('on-load') | |
const app = choo() | |
const page1 = (params, state, send) => { | |
const tree = html` | |
<div> | |
<h1>Page 1</h1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const choo = require('choo') | |
const html = choo.view | |
const onload = require('on-load') | |
const app = choo() | |
app.model({ | |
state: { | |
title: 'Hello' | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.router((route) => [ | |
route('/', layouts.root(views.connect)), | |
route('/tables', layouts.root(layouts.database()), [ | |
route('/:name', layouts.root(layouts.database(views.tableRows, 'rows')), [ | |
route('/schema', layouts.root(layouts.database(views.tableSchema, 'schema'))), | |
route('/options', layouts.root(layouts.database(views.tableOptions, 'options'))) | |
]) | |
]) | |
]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var onload = require('on-load') | |
var yo = require('yo-yo') | |
function page1 () { | |
var tree = yo`<div>page1</div>` | |
onload(tree, function () { | |
console.log('page1 on') | |
}, function () { | |
console.log('page1 off') | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const choo = require('choo') | |
const html = require('choo/html') | |
const app = choo() | |
app.model({ | |
state: { | |
title: 'Hello' | |
}, | |
reducers: { | |
update: (data, state) => ({ title: data }) |