-
-
Save ulises/975b1843c13888a95ff7 to your computer and use it in GitHub Desktop.
This file contains 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
(defn rich-stream* | |
[name state-thunk f] | |
(println name) | |
(println "State:" @state/streams) | |
(if-let [warm-state (get @state/streams name)] | |
(do (println "Using warm-state:" warm-state) | |
(f warm-state)) | |
(let [state (state-thunk)] | |
(do (println "Using cold state:" state) | |
(swap! state/streams assoc f state) | |
(f state))))) | |
(defmacro rich-stream | |
[state-thunk f] | |
`(rich-stream* (list 'quote ~f) ~state-thunk ~f)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment