Last active
November 14, 2017 19:45
-
-
Save matthewp/530cfb69c32a03cf1c1e158626e1da7c to your computer and use it in GitHub Desktop.
steal-tools --watch mode example
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
package-lock.json | |
node_modules/ | |
dist/ |
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
class Home { | |
constructor() { | |
this.count = 0; | |
} | |
start() { | |
if(!this.started) { | |
this.started = true; | |
setInterval(() => this.increment(), 2000); | |
} | |
} | |
increment() { | |
let count = ++this.count; | |
let counter = this.root.querySelector("#counter"); | |
counter.textContent = count; | |
} | |
render() { | |
this.start(); | |
let root = this.root = document.createElement("div"); | |
root.innerHTML = ` | |
<div id="counter"></div> | |
`; | |
this.increment(); | |
return root; | |
} | |
} | |
module.exports = Home; |
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
<!doctype html> | |
<html lang="en"> | |
<title>An app with watch mode</title> | |
<main></main> | |
<script src="./dist/steal.production.js"></script> |
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
const Home = require("./home"); | |
let main = document.querySelector("main"); | |
main.appendChild(new Home().render()); |
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": "watch-app", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"serve": "http-server -p 8081", | |
"watch": "steal-tools --watch", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"http-server": "^0.10.0", | |
"steal": "^1.6.0", | |
"steal-tools": "^1.9.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment