Created
November 15, 2013 23:10
-
-
Save cap10morgan/7493266 to your computer and use it in GitHub Desktop.
core.async HTML5 geolocation in ClojureScript
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 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