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
// file: example1/importantcheckbox.ts | |
// imports omitted | |
type localProps = { | |
model: ImportantCheckBoxModel, | |
} | |
type localState = { | |
important: boolean; // needs to match the <boolean> of the attribute in model | |
} |
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
// 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); |
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
// 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 |
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
// imports omitted | |
export type ImportantCheckBoxModel = { | |
important: Attribute<boolean>; | |
} |
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 main | |
import "somedwarf" | |
import "fmt" | |
type Sleepy struct {} | |
type IsHappy interface { | |
Happy() bool | |
} |
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 somedwarf | |
type Grumpy struct {} | |
func (g Grumpy) Happy() bool { | |
return false | |
} |
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
type Animal interface { //new and improved! | |
NumberOfLegs() int | |
Genus() string | |
} |
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
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 {} |
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
type Animal interface { | |
NumberOfLegs() int | |
} |
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
// +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. |
NewerOlder