Skip to content

Instantly share code, notes, and snippets.

View mjstahl's full-sized avatar
💡
Spend your money to make money. Spend your time helping others.

Mark Stahl mjstahl

💡
Spend your money to make money. Spend your time helping others.
View GitHub Profile
@mjstahl
mjstahl / hello-thing.js
Last active August 15, 2019 20:58
Trying out web components
class HelloThing extends HTMLElement {
static get observedAttributes () {
return ['thing']
}
constructor () {
super()
this.attachShadow({ mode: 'open' })
this.render()
}
@mjstahl
mjstahl / simple-fetch-async.html
Last active July 24, 2019 18:43
Simple async fetch example in Elementree
<!DOCTYPE html>
<html>
<body>
<script type="module">
import { merge, prepare, render } from 'https://unpkg.com/elementree'
function Hello (state) {
if (!state.email) state.requestUser()
return render`
<body>
@mjstahl
mjstahl / class-constructor-proxy.js
Created June 12, 2019 19:33
Proxy the context of a class expression
// Thanks @BigAB
class Counter {
constructor() {
setTimeout(this.onTick.bind(this), 1000);
}
onTick() {
const now = new Date();
// want to call the set trap
this.hours = now.getHours();
@mjstahl
mjstahl / constructor-proxy.js
Created June 12, 2019 19:31
Proxy the context of a constructor function
// Thanks @phillipskevin
function wrap(C) {
const instanceHandler = {
set(target, property, value, receiver) {
console.log(property, value);
return true;
}
}
@mjstahl
mjstahl / built.html
Created December 10, 2018 21:07
Differences in import between developer and built version when using steal-tools to build an app or dev bundle
<!DOCTYPE html>
<html>
<body>
<script src="./dist/steal.production.js" main></script>
</body>
</html>