In this other app I keep getting a IllegalStateException: Attempt to mutate in notification. Maybe this simplified example helps me solving it!
Simply type lein run.
| (ns problem | |
| "Test two-way bindings on text fields" | |
| (:use [seesaw.core] | |
| [seesaw.bind :only [bind b-swap! tee transform]]) | |
| (:gen-class)) | |
| (defn -main | |
| "Create a frame with a text field, bind it to an atom" | |
| [& args] | |
| (let [s (label) | |
| t (text) | |
| u (text :enabled? false) | |
| a (atom {:text ""})] | |
| ;; In this other project I keep getting a | |
| ;; IllegalStateException: Attempt to mutate in notification | |
| ;; ... | |
| (bind | |
| a (tee | |
| (bind (transform :text) s) | |
| (bind (transform :text) t) | |
| (bind (transform :text) u))) | |
| (bind t | |
| (b-swap! a #(assoc %1 :text %2))) | |
| ;; just for debugging | |
| (add-watch a :state-update | |
| (fn [key ref old new] | |
| (println (str "state changed to" new)))) | |
| (-> (frame :title "test binding" | |
| :on-close :exit | |
| :content (vertical-panel | |
| :items [s t u])) pack! show!))) |
| (defproject binding-problem "0.1.0-SNAPSHOT" | |
| :description "FIXME: write description" | |
| :url "http://example.com/FIXME" | |
| :license {:name "Eclipse Public License" | |
| :url "http://www.eclipse.org/legal/epl-v10.html"} | |
| :dependencies [[org.clojure/clojure "1.6.0"] | |
| [seesaw "1.4.5"]] | |
| :source-paths ["./"] | |
| :main ^:skip-aot problem | |
| :target-path "target/%s" | |
| :profiles {:uberjar {:aot :all}}) |