Browse files

Renamed seesaw.invoke/signaller to seesaw.invoke/signaller* and intro…

…duced a helper macro, signaller. This is a (minor) breaking change.
  • Loading branch information...
1 parent 6ba262a commit dac4b577d2c3fefb8065779dd21bc29b84155249 @daveray committed Dec 18, 2011
Showing with 23 additions and 8 deletions.
  1. +18 −1 src/seesaw/invoke.clj
  2. +3 −5 test/seesaw/test/examples/pi.clj
  3. +2 −2 test/seesaw/test/invoke.clj
View
19 src/seesaw/invoke.clj
@@ -78,7 +78,7 @@
"
[& body] `(invoke-soon* (fn [] ~@body)))
-(defn signaller
+(defn signaller*
"Returns a function that conditionally queues the given function (+ args) on
the UI thread. The call is only queued if there is not already a pending call
queued.
@@ -123,3 +123,20 @@
(reset! active? false)))
do-it))))
+(defmacro signaller
+ "Convenience form of (seesaw.invoke/signaller*).
+
+ A use of signaller* like this:
+
+ (signaller* (fn [x y z] ... body ...))
+
+ can be written like this:
+
+ (signaller [x y z] ... body ...)
+
+ See:
+ (seesaw.invoke/signaller*)
+ "
+ [args & body]
+ `(signaller* (fn ~args ~@body)))
+
View
8 test/seesaw/test/examples/pi.clj
@@ -75,10 +75,9 @@
progress (config! (select root [:#progress]) :max steps :value 0)
task (init-task 4 step-size steps)]
(add-watch (:result task) (gensym)
- (seesaw.invoke/signaller
- (fn [k r o {:keys [value count]}]
+ (seesaw.invoke/signaller [k r o {:keys [value count]}]
(config! progress :value count)
- (text! result-label (format "\u03C0 = %.20f" value)))))
+ (text! result-label (format "\u03C0 = %.20f" value))))
(reset! current-task (start-task task))))
(defn cancel [e]
@@ -161,8 +160,7 @@
(defexample []
(-> (make-frame)
(apply-stylesheet stylesheet)
- (apply-behaviors behaviors)
- ))
+ (apply-behaviors behaviors)))
;(run :dispose)
View
4 test/seesaw/test/invoke.clj
@@ -30,10 +30,10 @@
(deliver p {:edt? (javax.swing.SwingUtilities/isEventDispatchThread)}))))
(expect (= {:edt? true} @p)))))
-(describe signaller
+(describe signaller*
(it "should not invoke a call if one is already in flight"
(let [call-count (atom 0)
- signal (signaller #(swap! % inc))]
+ signal (signaller* #(swap! % inc))]
; Schedule some signals and check that only the first is queued.
(expect (= [true false false] (invoke-now [(signal call-count) (signal call-count) (signal call-count)])))
; Now check the call count and make sure only one function was queued

0 comments on commit dac4b57

Please sign in to comment.