Advertisement
Guest User

Untitled

a guest
Oct 15th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;; store
  2. (defn find-by-id [id]
  3.   {})
  4.  
  5. (defn find-friends-of [id]
  6.   [])
  7.  
  8. (defn find-last-post-of [id]
  9.   {})
  10.  
  11. ;; core
  12. (defn user [service id]
  13.   (service id))
  14.  
  15. (defn friends [service id]
  16.   (service id))
  17.  
  18. (defn last-post-of [service id]
  19.   (service id))
  20.  
  21. (defn user+friends+last-post [user-service friends-service last-post-service id]
  22.   (let [user (user-service id)
  23.         friends (friends-service id)
  24.         friends+last-posts (map #(assoc % :post (last-post-service (:id %))) friends)]
  25.     (assoc user :friends friends+last-posts)))
  26.  
  27. ;; public
  28. (def user (partial user find-by-id))
  29.  
  30. (def friends (partial friends find-friends-of))
  31.  
  32. (def last-post-of (partial last-post-of find-last-post-of))
  33.  
  34. (def user+friends+last-post
  35.   (partial user+friends+last-post find-by-id find-friends-of find-last-post-of))
  36.  
  37. ;; client
  38. (user 1)
  39. (friends 1)
  40. (last-post-of 2)
  41. (user+friends+last-post 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement