Skip to content

Instantly share code, notes, and snippets.

@matthewp
Last active November 14, 2017 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewp/530cfb69c32a03cf1c1e158626e1da7c to your computer and use it in GitHub Desktop.
Save matthewp/530cfb69c32a03cf1c1e158626e1da7c to your computer and use it in GitHub Desktop.
steal-tools --watch mode example
package-lock.json
node_modules/
dist/
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;
<!doctype html>
<html lang="en">
<title>An app with watch mode</title>
<main></main>
<script src="./dist/steal.production.js"></script>
const Home = require("./home");
let main = document.querySelector("main");
main.appendChild(new Home().render());
{
"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