Created
April 1, 2021 13:23
-
-
Save FiV0/c24f2a9ef665167cd26c7a4847de1270 to your computer and use it in GitHub Desktop.
Checking for inactivity in ClojureScript
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 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