This file contains hidden or 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
(ns test.core | |
(:require-macros [cljs.core.async.macros :refer [go]]) | |
(:require [cljs.core.async :refer [<! chan put!]] | |
[om.core :as om :include-macros true] | |
[om.dom :as dom :include-macros true])) | |
(enable-console-print!) | |
(def aidc (chan)) |
This file contains hidden or 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
(extend-type number | |
ICloneable | |
(-clone [n] (js/Number. n))) | |
(meta | |
(specify 1 | |
IMeta | |
(-meta [_] {:woot true}))) | |
;; => {:woot true} |
This file contains hidden or 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
(ns example) | |
(defrecord HTTPRequest [type url proxy]) | |
(HTTPRequest/getBasis) | |
;; => | |
;; [type url proxy] | |
(defrecord HTTPProxy [host port]) |
This file contains hidden or 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
<html> | |
<head> | |
</head> | |
<body> | |
<div id="test"></div> | |
<script src="http://fb.me/react-0.5.1.js"></script> | |
<script src="test.js"></script> | |
</body> | |
</html> |
This file contains hidden or 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
; using 2120 | |
(defprotocol P (m [x])) | |
(extend-protocol P | |
number | |
(m [x] (- x))) | |
(set! (.-foo js/Number.prototype) | |
#(this-as this (m this))) |
This file contains hidden or 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
var Counter = React.createClass({ | |
getInitialState: function() { | |
window.aCounter = this; | |
return { | |
count: 0 | |
}; | |
}, | |
add: function() { | |
this.setState({count: this.state.count+1}); |
This file contains hidden or 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
(ns react-cljs.core | |
(:require-macros [cljs.core.async.macros :refer [go]]) | |
(:require [om.core :as om] | |
[om.dom :as dom :include-macros true] | |
[cljs.core.async :refer [>! <! chan put! sliding-buffer]])) | |
(enable-console-print!) | |
(def app-state | |
(atom {:counters (into [] (map (fn [n] {:id n :count 0}) (range 10)))})) |
This file contains hidden or 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
(ns react-cljs.core | |
(:require-macros [reactjs.macros :refer [pure]]) | |
(:require React [reactjs.core :as r])) | |
(enable-console-print!) | |
(declare render-ui) | |
(defn render-counter [id state cb] | |
(pure state |
This file contains hidden or 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
var PureComponent = React.createClass({ | |
shouldComponentUpdate: function(nextProps, nextState) { | |
return !equals(this.props.value, nextProps.value); | |
}, | |
render: function() { | |
return this.props.children(); | |
} | |
}); | |
var pure = function(value, childrenThunk) { |
This file contains hidden or 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
(ns react-cljs.core | |
(:require React)) | |
(enable-console-print!) | |
(declare render-ui) | |
(defn render-counter [id state root] | |
(let [cnt (or (get-in state [id :count]) 0)] | |
(React/DOM.div nil |