This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-16
Channels
- # aleph (2)
- # beginners (68)
- # boot (25)
- # bristol-clojurians (5)
- # cider (10)
- # cljs-dev (60)
- # cljsrn (1)
- # clojure (138)
- # clojure-austin (1)
- # clojure-france (2)
- # clojure-greece (11)
- # clojure-italy (4)
- # clojure-russia (16)
- # clojure-spec (4)
- # clojure-uk (75)
- # clojurescript (26)
- # core-async (28)
- # cursive (25)
- # data-science (4)
- # datomic (16)
- # defnpodcast (2)
- # devops (2)
- # docs (10)
- # duct (11)
- # emacs (1)
- # events (1)
- # figwheel (8)
- # fulcro (61)
- # garden (2)
- # hoplon (6)
- # java (6)
- # jobs-discuss (1)
- # lein-figwheel (14)
- # leiningen (86)
- # luminus (11)
- # off-topic (8)
- # parinfer (9)
- # pedestal (2)
- # re-frame (19)
- # reagent (1)
- # ring (3)
- # ring-swagger (8)
- # shadow-cljs (278)
- # spacemacs (13)
- # sql (5)
- # testing (7)
- # unrepl (8)
- # yada (25)
Hello, I was wondering if there is a way to make the clojurescript core.async work in a way such that it will continue to run it's event-loop while a given web application isn't the currently open tab in browsers like chrome
From what I can tell, it's using requestAnimationFrame, which doesn't fire if the window isn't open. Is there a way to force it to fallback to use timeouts, or somehow have it fallback only when it isn't open?
@tbaldridge @alexmiller you're right, I'm not verbalizing this correctly
@benzap wouldn’t it be the browser itself controlling whether timeOut events actually fire in nonfocused tabs?
or can you verify normal timeOut works in background tabs but not core.async?
If I do a small test in the console, it appears to fire the timeout after the specified time, even when I unfocus the tab
interesting
so I set a timer for 10s using core.async logic, and opened a different tab in firefox
it's possible that firefox doesn't have setImmediate, so it falls back to some sort of a timeout when compared to the other two browsers, but i'm not sure at this point
If I could somehow figure out a way to check when the current javascript environment is closed, I could switch the core.async event loop over to a setTimeout fallback
Alright, so I messed around with it, and it turns out that core.async does run while the window is not focused, but at reduced tick rate
However, the ui event loop doesn't appear to work. There is no re-render of a react dom, which is why certain functionality that I want to work, won't. I'm assuming the react re-render is done via requestAnimationFrame
as a user I don't want a page that I am not looking that doing anything, which is, as I understand it, largely the reason some browsers have reduced what they can do
The web app i'm writing is a timer, without the changes it would never play an alarm when the timer has finished.