Last active
August 29, 2015 13:57
-
-
Save johnbintz/9497662 to your computer and use it in GitHub Desktop.
def.run for ClojureScript and AngularJS
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
(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