Skip to content

Instantly share code, notes, and snippets.

View iansmith's full-sized avatar

Ian Smith iansmith

  • [stealth-ish]
  • Atlanta GA
  • 12:14 (UTC -04:00)
  • X @iansmith
View GitHub Profile
@iansmith
iansmith / importantcheckbox.ts
Created March 24, 2021 16:39
from evalvite article, type decls for important checkbox
// file: example1/importantcheckbox.ts
// imports omitted
type localProps = {
model: ImportantCheckBoxModel,
}
type localState = {
important: boolean; // needs to match the <boolean> of the attribute in model
}
@iansmith
iansmith / importantcheckbox.ts
Last active March 24, 2021 17:13
from evalvite article, definition of component
// file: example1/importantcheckbox.ts
// imports omitted
export default class ImportantCheckBox extends React.Component<
localProps,
localState
> {
msg = "this is my message, there are many like it but this one is mine";
constructor(props: localProps) {
super(props);
ev.bindModelToComponent<ImportantCheckBoxModel>(this.props.model, this);
@iansmith
iansmith / models.ts
Last active March 24, 2021 17:08
from article on evalvite, example 3 models from dist
// file: example3/models.ts
// model for one input box
export interface NumberModelItem {
[key: string]: any;
value: Attribute<number>;
}
// … other models omitted
export default class NumberModel {
[key: string]: any;
// array content has to be an object, can't be just ArrayAttribute<number>; see NaiveArrayAttribute if you want to do an array of number
@iansmith
iansmith / models.ts
Last active March 24, 2021 16:27
from bury redux article: models.ts
// imports omitted
export type ImportantCheckBoxModel = {
important: Attribute<boolean>;
}
package main
import "somedwarf"
import "fmt"
type Sleepy struct {}
type IsHappy interface {
Happy() bool
}
package somedwarf
type Grumpy struct {}
func (g Grumpy) Happy() bool {
return false
}
type Animal interface { //new and improved!
NumberOfLegs() int
Genus() string
}
type Spider struct {}
func (s Spider) NumberOfLegs() int {
return 8
}
func (s Spider) Genus() {
return “Latrodectus” //strictly speaking, the genus of Black Widow spider
}
type Dog struct {}
type Animal interface {
NumberOfLegs() int
}
@iansmith
iansmith / frob.go
Created November 8, 2019 17:47
one file for a HTML generation tool from go -- also has some support for bootstrap 4 classes
// +build wasm
//
// The value returned by a tag name function is actually a function (closure) that can be
// instantiated by invoking it with a particular document.
//
// The params to a tag name function can be other tag name functions, Text() to
// set innerHtml, Attribute{attrName:"value"}, Events{eventName:handlerFunc},
// or Clazz (css classes) names. If you pass something else, the tag name
// functions panic.