Skip to content

Instantly share code, notes, and snippets.

@yuanmai
Created January 21, 2013 14:36
Show Gist options
  • Select an option

  • Save yuanmai/4586501 to your computer and use it in GitHub Desktop.

Select an option

Save yuanmai/4586501 to your computer and use it in GitHub Desktop.
deliver / promise, look ma no callbacks
(defn check-item [p id]
(if-let [item (find-item id)]
(do (deliver p item)
nil)
(status 404 "Item not found")))
(defn check-access [item]
(when-not (can-user-access? item)
(status 403 "Go away")))
(let [itemp (promise)]
(or (check-item itemp id)
(check-access @itemp)
(do
(other-stuff-with @itemp)
(redirect "/some-where"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment