Skip to content

Instantly share code, notes, and snippets.

@cap10morgan
Created November 15, 2013 23:10
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cap10morgan/7493266 to your computer and use it in GitHub Desktop.
Save cap10morgan/7493266 to your computer and use it in GitHub Desktop.
core.async HTML5 geolocation in ClojureScript
(ns cljs-minimal.core
(:require [cljs.core.async :as async :refer [put! <! >! <!! >!! chan]])
(:require-macros [cljs.core.async.macros :as m :refer [go]]))
(defn get-position []
(let [out (chan)
geo (.-geolocation js/navigator)]
(.getCurrentPosition geo (fn [pos] (put! out pos)))
out))
(go
(let [coords (.-coords (<! (get-position)))
latitude (.-latitude coords)
longitude (.-longitude coords)]
(.log js/console "Lat:" latitude "Long:" longitude)))
(.log js/console "After the go block")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment