Skip to content

Instantly share code, notes, and snippets.

@ulises
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ulises/4f9e5490fc872789d535 to your computer and use it in GitHub Desktop.
Save ulises/4f9e5490fc872789d535 to your computer and use it in GitHub Desktop.
(defn rich-stream*
[name state-thunk f]
(if-let [warm-state (get @state/streams name)]
(f warm-state)
(let [state (state-thunk)]
(swap! state/streams assoc name state)
(f state))))
(defmacro rich-stream
[state-thunk f]
`(rich-stream* (quote ~f) ~state-thunk ~f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment