Created
April 1, 2014 00:48
-
-
Save shinmuro/9905624 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; http://docs.oracle.com/javase/8/javafx/properties-binding-tutorial/binding.htm#JFXBD107 | |
;; の Example 1-7 Using the Low-Level API のサンプルを Clojure REPL で動くように書いてみた | |
(import javafx.beans.binding.DoubleBinding | |
javafx.beans.property.SimpleDoubleProperty) | |
(def a (SimpleDoubleProperty. 1)) | |
(def b (SimpleDoubleProperty. 2)) | |
(def c (SimpleDoubleProperty. 3)) | |
(def d (SimpleDoubleProperty. 4)) | |
(def db | |
(proxy [DoubleBinding] [] | |
(bind [] (proxy-super bind a b c d)) | |
(computeValue [] | |
(+ (* (.get a) (.get b)) (* (.get c) (.get d)))))) | |
(.computeValue db) | |
; => 14.0 | |
(.set b 3) | |
; => nil | |
(.computeValue db) | |
; => 15.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment