问题
As exercise to gain experience with ClojureScript I am writing a LightTable Plugin and I find no way to successfully use any standard library, I read the official documentation and even updated it to reflect latest changes regarding paths etc.. I followed this video and read the whole thread on the google group trying the proposed solutions, even working with the latest github source without luck.
I tried including core.async
or cljs.http
(I know the embedded nodejs alternative, just as example) following the proposed workflow by Irakli on the Google discussion. Simplest possible scenario:
$ lein version
Leiningen 2.5.0 on Java 1.7.0_55 Java HotSpot(TM) 64-Bit Server VM (Mac OS X 10.9.5) and LT latest (0.7.2)
$ lein new lt-plugin sample
plugin project.clj->
(defproject sample "0.0.1"
:dependencies [[org.clojure/clojure "1.5.1"]
[cljs-http "0.1.20"]
])
core file
(ns lt.plugins.sample
(:require [lt.object :as object]
[lt.objs.tabs :as tabs]
[lt.objs.command :as cmd]
[cljs-http.client :as http]
)
(:require-macros [lt.macros :refer [defui behavior]]))
(defn get-users
""
[]
(let [response (http/get "https://api.github.com/users" {:with-credentials? false})]
(prn (:status response))
(prn (map :login (:body response))))) ; evaluated correctly
(get-users) ; loads of errors like
WARNING: Referred var clojure.string/split does not exist at line 1 file:/Users/jaime/.m2/repository/noencore/noencore/0.1.16/noencore-0.1.16.jar!/no/en/core.cljs
I run lein deps, save, reload behaviours, restart, refresh plugin lists... all possible combinations tried, with the plugin folder within ~/Library/Application Support/LightTable/plugins
or outside.
Should I download the jars and put them manually into a lib folder? I guess lein deps
is not working as I expect
回答1:
Yes currently seems that Cljs native or Cljx for that matter, doesn't resonate well with the LightTable UI.
Trying https://github.com/swannodette/om/wiki/Basic-Tutorial you'll find that it doesn't take much. You can create a LT keybinding to open browser tab, navigate to project folder index.html
and make another for reloading (as autoreload is a work in progress I think). Then another tab with the Cljs file while you have the cljsbuild auto running, refresh browser and changes should be witnessed.
来源:https://stackoverflow.com/questions/27062382/how-to-integrate-libraries-clojars-into-lightable-plugins