Reputation: 58786
I have an application in clojure making heavy use of a Java framework called Vaadin. Vaadin uses several callbacks using the Java "proxy" feature of clojure. However, every time a proxy is called in a clojure function there is a significant delay (100s of milliseconds sometimes). Is there any way I can speed this up?
Upvotes: 3
Views: 405
Reputation: 32284
My understanding is that the new reify
macro is faster than proxy
. You can use it if you only need to implement a single interface.
For example, if you need to implement a java.awt.event.ActionListener
you can use code like the following:
(import 'java.awt.event.ActionListener 'javax.swing.JButton)
(let [a-button (JButton. "Click Me")]
(.addActionListener a-button
(reify ActionListener
(actionPerformed [this ev] (comment do something interesting)))))
Upvotes: 6