jack-in into normal Clojure nREPL. Run:
(require '[cljs.repl :as repl] '[cljs.repl.node :as node])
(compile 'cljs.repl.node)
(cemerick.piggieback/cljs-repl (cljs.repl.node/repl-env))
function createReducer(handlers, initialState) { | |
return function reducer(state = initialState, action) { | |
return handlers[action.type] ? | |
handlers[action.type](state, action) | |
: state | |
} | |
} | |
const math = createReducer({ | |
INCREMENT: (state) => state + 1, |
// radians->degrees | |
function degrees(radians) { | |
return radians * 180 / Math.PI; | |
} | |
// gets two positions { x: Number, y: Number } and return | |
// angle between them in radians | |
function getAngle(pos1, pos2 = {x: 0, y: 0}) { | |
let [dx, dy] = [pos1.x - pos2.x, (pos1.y - pos2.y) * -1] | |
return Math.atan2(dy, dx); |
jack-in into normal Clojure nREPL. Run:
(require '[cljs.repl :as repl] '[cljs.repl.node :as node])
(compile 'cljs.repl.node)
(cemerick.piggieback/cljs-repl (cljs.repl.node/repl-env))
(defn button [props _] | |
(om/component | |
(dom/button nil (:children props)))) | |
(def render-out (om/render-to-object button {:children "text"})) | |
(is (= "text" (:children render-out)) |
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- TeXML files must contain the Response element --> | |
<Response> | |
<!-- Say and Dial are Verbs --> | |
<Say>Thank you for calling Telnyx.</Say> | |
<Dial> | |
<Sip>sip:gencredhoj84HXAATNAXTfLJBkZBFv0sr@sip.telnyx.com</Sip> | |
</Dial> | |
</Response> |
import { createMachine, assign } from "xstate"; | |
type MachineContext = { | |
lives: number; | |
}; | |
type MachineEvent = | |
| { type: "IDLE" } | |
| { type: "WALK" } | |
| { type: "RUN" } |