Hi!

I'm running lein figwheel app

And in controller I write the code to be executed with cljs.js/eval
I want that eval would see my defined functions.

Lets look at example below, especially on sstr function and  button/on-click 
callback:

(ns cljs-eval-example.core
    (:require
[cljs.tools.reader :refer [read-string]]
[cljs.js :refer [empty-state eval js-eval]]
            [reagent.core :as reagent :refer [atom]]
              [reagent.session :as session]
              [secretary.core :as secretary :include-macros true]
              [accountant.core :as accountant]))



(defn sstr [ & prms ]
(apply str (flatten arms)))


(defn eval-str [s]
    (eval (empty-state)
    (read-string s)
    {:eval       js-eval

    :source-map true
    :context    :expr}
        (fn [result] result)))


(defn home-page []
  [:div [:h2 "Welcome to cljs-eval-example"]
   [:div [:a {:href "/about"} "go to about page"]]
[:div [:button
{:on-click #(eval-str "(println (sstr [ \"hello world!\" \"asda\" ]))")}
"let's compile!"]]
        ])



The problem is that sstr during evaluation is not visible.
I have read that eval can accept :ns attribute for opts and probably it defines 
default namespace
but I have no idea how to use that. Any help?
I want to define set of functions and macros (I have read that these should be 
in another compilation unit) which will be available during evaluation (in fact 
I want to just execute the AST from another language).

Another question is if I write the whole code in that web framework, will I be 
able to compile it for static pages (html+js) to be executed on an user browser?

Thanks in advance!



-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/clojurescript.

Reply via email to