Skip to content

Instantly share code, notes, and snippets.

View sunho's full-sized avatar
🐈
math is beutiful

Sunho Kim sunho

🐈
math is beutiful
View GitHub Profile
func LoadParsers(customParsers map[reflect.Type]Parser) (map[reflect.Type]Parser, error) {
parsers := map[reflect.Type]Parser{}
var boolParser BoolValue
parsers[reflect.TypeOf(true)] = &boolParser
var intParser IntValue
parsers[reflect.TypeOf(1)] = &intParser
var int64Parser Int64Value
My presentational components:
Are concerned with how things look.
May contain both presentational and container components** inside, and usually have some DOM markup and styles of their own.
Often allow containment via this.props.children.
Have no dependencies on the rest of the app, such as Flux actions or stores.
Don’t specify how the data is loaded or mutated.
Receive data and callbacks exclusively via props.
Rarely have their own state (when they do, it’s UI state rather than data).
Are written as functional components unless they need state, lifecycle hooks, or performance optimizations.
var colors:Array = ["red","blue","green"];
var buttons:Array = new Array();
function colorSwitch(frame:Number) {
return function(e:MouseEvent) {
color.gotoAndStop(frame);
}
}
for (var i=0;i<colors.length;i++) {
buttons[i]=new button;
buttons[i].y=30*i;
function click(frame:Number) {
return function(e:MouseEvent) {
if(e.target.currentFrame == 1) {
e.target.gotoAndStop(frame);
} else {
e.target.gotoAndStop(1);
}
}
}
button1.addEventListener(MouseEvent.CLICK,click(2));
function click(e:MouseEvent) {
if(e.target.currentFrame == 1) {
e.target.gotoAndStop(2);
} else {
e.target.gotoAndStop(1);
}
}
button1.addEventListener(MouseEvent.CLICK,click);
button2.addEventListener(MouseEvent.CLICK,click);
button1.addEventListener(MouseEvent.CLICK, function(e:MouseEvent) {
if(button1.currentFrame == 1) {
button1.gotoAndStop(2);
} else
button1.gotoAndStop(1);
}
});
button2.addEventListener(MouseEvent.CLICK, function(e:MouseEvent) {
if(button2.currentFrame == 1) {
button2.gotoAndStop(2);
toggleDetails() {
this.setState({
showDetails: !this.state.showDetails
});
}
func badtype(expected string, data interface{}) error {
return e("cannot load TOML value of type %T into a Go %s", data, expected)
}
if item, ok := cmd.Commands[parms[0]]; ok {
s := string(byteArray[:])