(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
package org.devboy; | |
import haxe.macro.Type; | |
import neko.Lib; | |
import haxe.macro.Expr; | |
import haxe.macro.Context; | |
class Funk | |
{ |
<?xml version="1.0" encoding="utf-8"?> | |
<project> | |
<!-- <meta /> | |
Use meta nodes to set metadata for your application. The description is ignored | |
on most targets, but is useful for packaging like Chrome Apps or Opera Widgets. | |
For compatibility with Android and webOS, the package name must include at least |
.PHONY: compile | |
time=/usr/bin/time | |
compile: dart typescript coffeescript haxe jsx | |
dart: | |
$(time) dart2js -ooutput/dart.js source/simple.dart | |
typescript: |
import haxe.macro.Context; | |
import haxe.macro.Expr; | |
import haxe.macro.Type; | |
using Lambda; | |
/** | |
Old school abstract class. | |
Classes that implements it, and their sub-classes, will be able to declare abstract methods (methods that without body). | |
There will be a check in compile-time such that no public constructor is allowed without all abstract methods implemented. | |
*/ |
import haxe.macro.Context; | |
import haxe.macro.Expr; | |
import haxe.macro.Type; | |
class AbstractBuilder { | |
macro static public function build():Array<Field> { | |
var fields = Context.getBuildFields(); | |
var cCur = Context.getLocalClass().get(); | |
var fieldMap = [for (f in fields) f.name => true]; | |
function loop(c:ClassType) { |
package ; | |
abstract JsonMap<T>({ }) from {} { | |
public function new() this = {}; | |
public function exists(key:String) return Reflect.hasField(this, key); | |
@:arrayAccess public function get(key:String) return Reflect.field(this, key); | |
@:arrayAccess public function set(key:String, value:T):T { | |
Reflect.setField(this, key, value); | |
return value; | |
} |
{ | |
"$schema": "http://json-schema.org/draft-04/schema#", | |
"description": "A haxelib project", | |
"type": "object", | |
"properties": { | |
"name": { "$ref": "#/definitions/name" }, | |
"license": { | |
"description": "The open source license under which the project is licensed", | |
"enum": ["GPL", "LGPL", "BSD", "Public", "MIT"] | |
}, |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
TLDR: a React component should either manage its own state, or expose a callback so that its parent can. But never both.
Sometimes our first impulse is for a component to entirely manage its own state. Consider this simple theater seating picker that has a letter for a row, and a number for a seat. Clicking the buttons to increment each value is hardly the height of user-interface design, but never mind - that's how it works:
/* @flow */
var React = require('react');
var Letter: React.ReactClass = React.createClass({
getInitialState: function(): any {
javascript:(function(e,a,g,h,f,c,b,d)%7Bif(!(f=e.jQuery)%7C%7Cg%3Ef.fn.jquery%7C%7Ch(f))%7Bc=a.createElement(%22script%22);c.type=%22text/javascript%22;c.src=%22http://ajax.googleapis.com/ajax/libs/jquery/%22+g+%22/jquery.min.js%22;c.onload=c.onreadystatechange=function()%7Bif(!b&&(!(d=this.readyState)%7C%7Cd==%22loaded%22%7C%7Cd==%22complete%22))%7Bh((f=e.jQuery).noConflict(1),b=1);f(c).remove()%7D%7D;a.documentElement.childNodes%5B0%5D.appendChild(c)%7D%7D)(window,document,%221.3.2%22,function($,L)%7B$('%23header,%20.pagehead,%20.breadcrumb,%20.commit,%20.meta,%20%23footer,%20%23footer-push,%20.wiki-actions,%20%23last-edit,%20.actions,%20.header,.site-footer,.repository-sidebar,.file-navigation,.gh-header-meta,.gh-header-actions,#wiki-rightbar,#wiki-footer').remove();%20$('%23files,%20.file').css(%7B%22background%22:%22none%22,%20%22border%22:%22none%22%7D);%20$('link').removeAttr('media');%7D); var removeMe = document.getElementsByClassName("file-header")[0]; removeMe.parentNode.removeChild(removeMe); |