Skip to content

Instantly share code, notes, and snippets.

@jellybob
Created December 13, 2012 23:58
Show Gist options
  • Save jellybob/4281249 to your computer and use it in GitHub Desktop.
Save jellybob/4281249 to your computer and use it in GitHub Desktop.
(def state
ref { :view-ns 'media-mogul.frontend.main-menu })
(defn- callback
[ name & args ]
; Rummages around in the specified namespace, extracts any public methods
; and then finds the one with the same name as the callback being requested.
;
; Then evals it for good measure.
(let [ callback-fn @(name (ns-publics (the-ns (:view-ns @state)))) ]
(eval (apply callback-fn args))))
(def application-proxy
(proxy [ BasicGame ] [ "Media Mogul" ]
(init [ container ])
(render [ container graphics ]
(callback 'render container graphics))
(update [ container delta ]
(callback 'update container delta))))
(defn update [ container delta ]
(.setTitle container "Hello world"))
(defn render [ container graphics ]
(.drawString graphics "Hello, world" 30 30))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment