Skip to content

Instantly share code, notes, and snippets.

@verma verma/cljs-macros.clj
Last active Aug 29, 2015

Embed
What would you like to do?
;; How I am requiring the macros:
;; core.cljs
(ns pre-k-adventures.core
(:require [pre-k-adventures.util :as util]
[cljs.core.match])
(:require-macros [cljs.core.match.macros :refer [match]]
[pre-k-adventures.macros :refer [offset-rand]]))
;; usage some where in core.cljs
;;
(fn [ctx img x y]
(blit-cell! ctx img 3 10 1 2 (offset-rand x 20) (offset-rand (- y 1) 4))
(blit-cell! ctx img 0 10 1 2 x (- y 1))
(blit-cell! ctx img 1 10 1 2 (offset-rand x 16) (offset-rand (- y 1) 10)))
;; macros.clj
(ns pre-k-adventures.macros)
(defmacro offset-rand [x by]
`(pre-k-adventures.util/offset-by ~x (- by (rand-int (* 2 by)))))
;; lein cljsbuild once (line 71 is where the macro is being used in core.cljs)
Compiling "js/main.js" from ["src"]...
WARNING: No such namespace: pre-k-adventures.macros at line 71 src/pre_k_adventures/core.cljs
WARNING: No such namespace: pre-k-adventures.macros at line 71 src/pre_k_adventures/core.cljs
WARNING: No such namespace: pre-k-adventures.macros at line 71 src/pre_k_adventures/core.cljs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.