Skip to content
Browse files

remove spurious # add in letrem

Signed-off-by: Chris Granger <ibdknox@gmail.com>
  • Loading branch information...
1 parent 93e17fe commit dbe44e16defd69fdeae6d8e784e383cc21f5db37 @ibdknox committed Aug 10, 2011
Showing with 17 additions and 4 deletions.
  1. +5 −0 README.md
  2. +12 −4 src/pinot/macros.clj
View
5 README.md
@@ -32,6 +32,11 @@ Remotes let you make calls to a noir server without having to think about XHR. O
(pm/remote (get-user 2) [{:keys [username age]}]
(js/alert (str "Name: " username ", Age: " age)))
+
+;;Also just added letrem
+(pm/letrem [a (adder 3 4)
+ b (adder 5 6)]
+ (js/alert (str "a: " a " b: " b)))
```
Note that the results we get are real Clojure datastructures and so we use them just as we would in normal Clojure code. No JSON here.
View
16 src/pinot/macros.clj
@@ -16,10 +16,18 @@
(defmacro remote
[[sym & params] & [destruct & body]]
- (let [func# (if destruct
- `(fn ~destruct ~@body)
- nil)]
+ (let [func (if destruct
+ `(fn ~destruct ~@body)
+ nil)]
`(pinot.remotes/remote-callback ~(name sym)
~(vec params)
- ~func#)))
+ ~func)))
+(defmacro letrem
+ [bindings & body]
+ (let [bindings (partition 2 bindings)]
+ (reduce
+ (fn [prev [destruct func]]
+ `(remote ~func [~destruct] ~prev))
+ `(do ~@body)
+ (reverse bindings))))

0 comments on commit dbe44e1

Please sign in to comment.
Something went wrong with that request. Please try again.