Skip to content

Instantly share code, notes, and snippets.

@ulsa
Created April 9, 2012 21:59
Show Gist options
  • Save ulsa/2346853 to your computer and use it in GitHub Desktop.
Save ulsa/2346853 to your computer and use it in GitHub Desktop.
ClojureScript code for accessing the Karotz toy rabbit
(ns clojurekarotz.core
(:require [clojurekarotz.util :as u]))
(def quit (fn [event] (if (= event "TERMINATED") (js/exit))))
(defn onKarotzConnect [data]
(.moveRelative (.-ears js/karotz) 5 -5 (fn [_]))
(.start (.-tts js/karotz) "Buenos dias Clojure. Como estas? Tienes animales?" "es" quit))
(.connectAndStart js/karotz "192.168.1.13" 9123 onKarotzConnect (js-obj))
var karotz = {};
karotz.connect = function() {};
karotz.start = function() {};
karotz.ears = function() {};
karotz.ears.moveRelative = function() {};
karotz.tts = function() {};
karotz.tts.start = function() {};
(defproject clojurekarotz "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:plugins [[lein-cljsbuild "0.1.6"]]
:dependencies [[org.clojure/clojure "1.3.0"]]
:cljsbuild {
:builds [
{:source-path "src"
:compiler {:output-to "main.js"
:optimizations :advanced
:pretty-print false
:externs ["externs.js"]}}]})
(ns clojurekarotz.util)
(set! (.-connectAndStart js/karotz)
(fn [host port callback data]
(try
(.connect js/karotz host port)
(js/log "connected")
(.start js/karotz callback data)
(catch js/Error e
(js/log e)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment