-
-
Save antoineB/2830a82227d881a9d90a to your computer and use it in GitHub Desktop.
This file contains 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
(defmacro goog-extend [type base-type ctor & methods] | |
`(do | |
(defn ~type ~@ctor) | |
(goog/inherits ~type ~base-type) | |
~@(map | |
(fn [method] | |
`(if (= \- (first (str (first method)))) | |
(set! (.. ~type -protitype ~(first method)) (second method)) | |
(set! (.. ~type -prototype ~(to-property (first method))) | |
(fn ~@(rest method)))) | |
methods))) | |
;; and use like | |
(ns move.views | |
(:require [goog.ui.tree.TreeControl :as TreeControl]) | |
(:use-macros [move.macros :only [goog-extend]] | |
[cljs.core :only [this-as]])) | |
(goog-extend | |
MyTree goog/ui.tree.TreeControl | |
([name config] | |
(this-as this | |
(goog/base this name config))) | |
(-notAfunction 12) | |
(handleKeyEvent | |
[e] | |
(this-as this | |
(goog/base this "handleKeyEvent" e) | |
;; my special code to handle the key event | |
))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment