Hi Frank,

That is pretty much exactly as I wanted. The only problem is that you are 
calling a private fn and therefore the code is susceptible to change. I 
think this should be looked into more and become officially supported. This 
is a great hook that opens up the door to a more interactive development 
experience for clojurescript.

On Tuesday, September 18, 2012 2:00:08 AM UTC-4, FrankS wrote:
>
> I have the same requirement to have a clojurescript-form in my 
> clojure-environment that I want to evaluate in the browser… 
>
> To make the following code-snippet work, you're supposed to have a 
> browser-repl session running, and start a new repl-session on that same JVM 
> from where you invoke the following forms to execute either javascript-code 
> or clojurescript-forms in the browser. 
>
> --- 
> user=> (require 'cljs.repl) 
> nil 
>
> user=> (require 'cljs.repl.browser) 
> nil 
>
> user=> (cljs.repl.browser/browser-eval "alert('No Way!')") 
> {:status :success, :value ""} 
>
> user=> (def my-repl-env {:port 9000, :optimizations :simple, :working-dir 
> ".lein-cljsbuild-repl", :serve-static true, :static-dir ["." "out/"], 
> :preloaded-libs []}) 
> #'user/my-repl-env 
>
> user=> (def my-env {:context :statement :locals {}}) 
> #'user/my-env 
>
> user=> (#'cljs.repl/eval-and-print my-repl-env my-env '(js/alert "Yes 
> Way!")) 
> nil 
> nil 
>
> user=> 
> --- 
>
> The public function "cljs.repl.browser/browser-eval" seems to allow you to 
> send javascript code as a string to the browser to execute over the 
> existing browser-repl connection. 
>
> The private function "cljs.repl/eval-and-print" will take a clojurescript 
> form, compile it to javascript and send it to the browser for execution. 
> The "my-repl-env" and "my-env" values are artifacts needed that are 
> normally only available within the context of the function. 
>
> My apology for this huge&ugly hack… please see it as a proof of principle. 
>
> There may be much more elegant solutions available… I've only scratch the 
> surface of understanding how this clojurescript repl works in detail. 
>
> -Enjoy, FrankS 
>
>
> On Sep 17, 2012, at 9:03 PM, Brent Millare <[email protected]<javascript:>> 
> wrote: 
>
> > And yes by eval I mean compile and run on the target (browser) 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to [email protected]<javascript:> 
> > Note that posts from new members are moderated - please be patient with 
> your first post. 
> > To unsubscribe from this group, send email to 
> > [email protected] <javascript:> 
> > For more options, visit this group at 
> > http://groups.google.com/group/clojure?hl=en 
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to