Skip to content

Instantly share code, notes, and snippets.

@mdallastella
Created July 31, 2017 13:24
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 mdallastella/59965ba34ded779852e79d2a9358e887 to your computer and use it in GitHub Desktop.
Save mdallastella/59965ba34ded779852e79d2a9358e887 to your computer and use it in GitHub Desktop.
(ns sessions)
(defn create-sessions
"Initialize the session atom."
[]
(atom []))
(defn put-session!
"Insert a session into the sessions atom."
[sessions session]
(swap! sessions conj session))
(defn has-session?
"Check if there are at least one session."
[sessions]
(not (empty? @sessions)))
(defn read-session
"Read ALWAYS the first element of sessions. TO BE IMPROVED!"
[sessions]
(first @sessions))
(defn reset-session!
"Reset the session atom."
[sessions]
(swap! sessions empty))
(ns sessions)
(defonce sessions (atom []))
(defn put-session!
"Insert a session into the sessions atom."
[session]
(swap! sessions conj session))
(defn has-session?
"Check if there are at least one session."
[]
(not (empty? @sessions)))
(defn read-session
"Read ALWAYS the first element of sessions. TO BE IMPROVED!"
[]
(first @sessions))
(defn reset-session!
"Reset the session atom."
[]
(swap! sessions empty))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment