Last active
February 5, 2018 17:07
-
-
Save callil/52db52b6786d053a84ad8190a46058d8 to your computer and use it in GitHub Desktop.
Choo onload
This file contains 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 choo = require('choo') | |
var html = require('choo/html') | |
var app = choo() | |
var main = require('./views/main.js') | |
var store = require('./stores/store.js') | |
app.use(store) | |
app.route('/', main) | |
// app.route('/about', about) | |
app.mount('body') |
This file contains 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
// import choo's template helper | |
const html = require('choo/html') | |
const onload = require('on-load') | |
module.exports = main | |
function main (state, emit) { | |
return html` | |
<body> | |
${welcome(state,emit)} | |
</body> | |
` | |
} | |
function welcome (state, emit) { | |
// create html template | |
let div = html` | |
<p>Welcome!</p> | |
` | |
// this throws the error Uncaught TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them | |
onload(div, (el) => { | |
console.log('Loaded') | |
}, (el) => { | |
console.log('Unloaded') | |
}) | |
return div | |
} |
This file contains 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
{ | |
"name": "onload", | |
"version": "1.0.0", | |
"private": true, | |
"scripts": { | |
"build": "bankai build index.js", | |
"create": "choo-scaffold", | |
"inspect": "bankai inspect index.js", | |
"start": "bankai start index.js", | |
"test": "standard && npm run test-deps", | |
"test-deps": "dependency-check . && dependency-check . --extra --no-dev -i tachyons" | |
}, | |
"dependencies": { | |
"choo": "^6.6.1", | |
"choo-devtools": "^2.3.2", | |
"choo-service-worker": "^2.3.1", | |
"on-load": "^3.3.4", | |
"sheetify": "^6.2.0", | |
"tachyons": "^4.9.1" | |
}, | |
"devDependencies": { | |
"bankai": "^9.1.0", | |
"choo-scaffold": "^1.1.2", | |
"dependency-check": "^2.9.2", | |
"standard": "^10.0.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment