Skip to content

Commit

Permalink
feat(Visualization): Pause data retrieval on visibility change
Browse files Browse the repository at this point in the history
  • Loading branch information
gremid committed Dec 23, 2024
1 parent 513c7c6 commit 5cf45b5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/dwds/livestream/viz.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,17 @@
(def start-rendering!
(partial listen-to-page-requests render-page-request))

(defn register-visibility-listener!
[]
(js/document.addEventListener
"visibilitychange"
(fn []
(if (.-hidden js/document)
(stop-event-retrieval!)
(start-event-retrieval!)))))

(defn ^:dev/after-load start!
[]
(register-visibility-listener!)
(start-rendering!)
(start-event-retrieval!))

0 comments on commit 5cf45b5

Please sign in to comment.