Skip to content

Instantly share code, notes, and snippets.

@johnbintz
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnbintz/9497662 to your computer and use it in GitHub Desktop.
Save johnbintz/9497662 to your computer and use it in GitHub Desktop.
def.run for ClojureScript and AngularJS
(defmacro def.run [sym params & body]
(list '.run ;; .run(
(list '.module 'js/angular sym) ;; angular.module(sym)
(concat ['array] ;; Array.new(
(map str params) ;; "$rootScope", "$q"
[(concat ['fn params] body)] ;; , function($rootScope, $q) { code; }))
)
)
)
(def.run "my-module" [$rootScope $q]
(let [deferred (.defer $q)]
(! $rootScope.cats "dogs")
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment