Browse files

Allow connections to the REPL from remote machines. Fixes #72.

  • Loading branch information...
1 parent 651d764 commit 6300d5b350d0f4fdfbf258d826b5224759545bba @brentonashworth brentonashworth committed Jan 17, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/app/cljs/one/sample/core.cljs
@@ -1,19 +1,27 @@
(ns ^{:doc "Contains the entry point for the ClojureScript sample application."}
- (:require [clojure.browser.repl :as repl]
+ (:require [goog.uri.utils :as uri]
+ [clojure.browser.repl :as repl]
[one.dispatch :as dispatch]
[one.sample.view :as view]))
;; **TODO:** Add marginalia comment to explain what `:export` is for.
+(defn- server
+ "Return a string which is the scheme and domain portion of the URL
+ for the server from which this code was served."
+ []
+ (let [location (.toString window.location ())]
+ (str (uri/getScheme location) "://" (uri/getDomain location))))
(defn ^:export repl
"Connects to a ClojureScript REPL running on localhost port 9000.
This allows a browser-connected REPL to send JavaScript to the
browser for evaluation. This function should be called from a script
in the development host HTML page."
- (repl/connect "http://localhost:9000/repl"))
+ (repl/connect (str (server) ":9000/repl")))
(defn ^:export start
"Start the application by firing a `:init` event which will cause the

0 comments on commit 6300d5b

Please sign in to comment.