Fixed: Nested run-now (and therefore nested build) won't work.
This commit is contained in:
parent
b6a2f308fa
commit
20aac63215
2 changed files with 12 additions and 9 deletions
|
@ -1,9 +1,9 @@
|
||||||
(defproject clojurefx "0.0.1"
|
(defproject clojurefx "0.0.2"
|
||||||
:description "Helper functions and probably a wrapper to simplify usage of JavaFX in Clojure.
|
:description "Helper functions and probably a wrapper to simplify usage of JavaFX in Clojure.
|
||||||
|
|
||||||
You'll need to have jfxrt.jar in your local maven repository. See [this coderwall protip](https://coderwall.com/p/4yjy1a) for how to make this happen.
|
You'll need to have jfxrt.jar in your local maven repository. See [this coderwall protip](https://coderwall.com/p/4yjy1a) for how to make this happen.
|
||||||
|
|
||||||
**Installation: `[clojurefx \"0.0.1\"]`**"
|
**Installation: `[clojurefx \"0.0.2\"]`**"
|
||||||
:url "https://www.github.com/zilti/clojurefx"
|
:url "https://www.github.com/zilti/clojurefx"
|
||||||
:license {:name "Eclipse Public License"
|
:license {:name "Eclipse Public License"
|
||||||
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
||||||
|
|
|
@ -11,16 +11,20 @@ Simple wrapper for Platform/runLater. You should use run-later.
|
||||||
(defmacro run-later [& body]
|
(defmacro run-later [& body]
|
||||||
`(run-later* (fn [] ~@body)))
|
`(run-later* (fn [] ~@body)))
|
||||||
|
|
||||||
|
(declare ^:dynamic *nested?*)
|
||||||
(defn run-now*"
|
(defn run-now*"
|
||||||
A modification of run-later waiting for the running method to return. You should use run-now.
|
A modification of run-later waiting for the running method to return. You should use run-now.
|
||||||
" [f]
|
" [f]
|
||||||
(let [result (promise)]
|
(let [result (promise)]
|
||||||
(run-later
|
(run-later
|
||||||
(deliver result (try (f) (catch Throwable e e))))
|
(deliver result (try (f) (catch Throwable e e))))
|
||||||
@result))
|
@result))
|
||||||
|
|
||||||
(defmacro run-now [& body]
|
(defmacro run-now [& body]
|
||||||
`(run-now* (fn [] ~@body)))
|
(if *nested?*
|
||||||
|
`((fn [] ~@body))
|
||||||
|
(binding [*nested?* true]
|
||||||
|
`(run-now* (fn [] ~@body)))))
|
||||||
|
|
||||||
(defn- camel [in]
|
(defn- camel [in]
|
||||||
(let [in (name in)
|
(let [in (name in)
|
||||||
|
@ -79,7 +83,7 @@ Don't use this yourself; See the macros \"build\" and \"deffx\" below.
|
||||||
(if (not (empty? (filter #(= % builder) (get pkgs k))))
|
(if (not (empty? (filter #(= % builder) (get pkgs k))))
|
||||||
(symbol (str k "." (camel (name builder))))))))))
|
(symbol (str k "." (camel (name builder))))))))))
|
||||||
|
|
||||||
(defmacro build"This helper macro makes it easier to use the [JavaFX builder classes](http://docs.oracle.com/javafx/2/api/javafx/util/Builder.html). You can also use a map, so it is possible to compose the arguments for the builder over time.
|
(defmacro build "This helper macro makes it easier to use the [JavaFX builder classes](http://docs.oracle.com/javafx/2/api/javafx/util/Builder.html). You can also use a map, so it is possible to compose the arguments for the builder over time.
|
||||||
|
|
||||||
**Examples:**
|
**Examples:**
|
||||||
|
|
||||||
|
@ -90,7 +94,6 @@ Don't use this yourself; See the macros \"build\" and \"deffx\" below.
|
||||||
(map? (first args)))
|
(map? (first args)))
|
||||||
`(build ~what ~@(for [entry# (keys (first args))]
|
`(build ~what ~@(for [entry# (keys (first args))]
|
||||||
`(~(symbol (name entry#)) ~((first args) entry#))))
|
`(~(symbol (name entry#)) ~((first args) entry#))))
|
||||||
|
|
||||||
`(run-now (.. ~(get-qualified what) ~(symbol "create")
|
`(run-now (.. ~(get-qualified what) ~(symbol "create")
|
||||||
~@args
|
~@args
|
||||||
~(symbol "build")))))
|
~(symbol "build")))))
|
||||||
|
|
Loading…
Reference in a new issue