Skip to content

Instantly share code, notes, and snippets.

@FiV0
Created April 1, 2021 13:23
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 FiV0/c24f2a9ef665167cd26c7a4847de1270 to your computer and use it in GitHub Desktop.
Save FiV0/c24f2a9ef665167cd26c7a4847de1270 to your computer and use it in GitHub Desktop.
Checking for inactivity in ClojureScript
(defn inactive[]
(js/console.log "You have been inactive!!!"))
(def timer (atom nil))
(defn reset-timer []
(js/clearTimeout @timer)
(swap! timer #(js/setTimeout inactive 3000)))
(defn inactivity-time []
(set! (.-onload js/window) reset-timer)
(set! (.-onmousemove js/document) reset-timer)
(set! (.-onkeypress js/document) reset-timer))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment