Skip to content

Instantly share code, notes, and snippets.

@mfikes
Created April 13, 2016 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfikes/2de7f559a1e9a5ae12c67dc506e92f3d to your computer and use it in GitHub Desktop.
Save mfikes/2de7f559a1e9a5ae12c67dc506e92f3d to your computer and use it in GitHub Desktop.
cljs.js state
cljs.user=> (require 'cljs.js)
nil
cljs.user=> (def st (cljs.js/empty-state))
#'cljs.user/st
cljs.user=> (cljs.js/eval-str st "(ns foo.core)" nil {:eval cljs.js/js-eval :context :expr} identity)
{:ns foo.core, :value nil}
cljs.user=> (cljs.js/eval-str st "(defn func [x] (inc x))" nil {:eval cljs.js/js-eval :context :expr :ns 'foo.core} identity)
{:ns foo.core, :value #object[foo$core$func "function foo$core$func(x){
return (x + (1));
}"]}
cljs.user=> (cljs.js/eval-str st "(func 3)" nil {:eval cljs.js/js-eval :context :expr :ns 'foo.core} identity)
{:ns foo.core, :value 4}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment