This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-26
Channels
- # aleph (9)
- # announcements (31)
- # babashka (23)
- # beginners (35)
- # biff (2)
- # calva (5)
- # cider (10)
- # clara (11)
- # clerk (114)
- # clj-kondo (18)
- # cljdoc (37)
- # clojars (7)
- # clojure (24)
- # clojure-austin (10)
- # clojure-europe (27)
- # clojure-nl (1)
- # clojure-norway (23)
- # clojure-uk (2)
- # clojurescript (18)
- # conjure (2)
- # core-async (6)
- # cursive (21)
- # datomic (3)
- # fulcro (15)
- # introduce-yourself (7)
- # lsp (32)
- # malli (57)
- # meander (5)
- # music (1)
- # nbb (2)
- # off-topic (17)
- # pathom (6)
- # rdf (4)
- # reagent (8)
- # releases (2)
- # shadow-cljs (4)
- # slack-help (23)
- # spacemacs (6)
- # tools-build (32)
I have a problem with js/MediaRecorder
that I can't figure out. The documentation for the stop
event guarantees me that a last call to dataavailable
has been made when the stop
event is fired: https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/stop_event
However, I need to wait a bit for the data to actually be in the place where I store it. Pseudo code:
recorder.ondataavailable -> (fn [ev-with-chunk] conj the chunks onto my vector of data chunks)
recorder.onstop -> (fn [] read the chunks from the vector of chunks)
Often in onstop, I do not have the last chunk. Especially on my phone. I have the chunks in the re-fram app-db, but I have the same problem if I use a reagent/atom
. Using reagent.core/next-tick
only improves the ratio of success/failure, it still fails at times. Assuming I can trust the docs, I obviously lack understanding about something important here... I really don't like to stick a js/setTimeout
in there!Either the events are out of order or your data storage impl is wrong.
You can confirm by logging the events and checking whether the last dataavailable
sometimes happens after stop
.
In case of re-frame, its events are queued and aren't executed immediately, so that would be easy an easy explanation. But you say you also tried using reagent/atom
, and I'm not sure what could go wrong there.
Thanks! Now I seem to get away with dispatch-sync
in dataavailable
together with next-tick
in stop
. Not sure I can trust it, yet. Will log like you suggest and see what that gives.
Using next-tick
to help with an up-to-one-tick delay won't save you from a more-than-one-tick delay.
Race conditions must not be solved with arbitrary delays.
Thanks. I guess I made the bet that these events always arrive in the order the docs say they do and then that dispatch-sync
would place the the next dispatch within a tick. But that was silly, I now think I understand. I removed the next-tick from onstop
and only do dispatch-sync
in ondataavilable
. It seems to work just as well.
It still leaves me wondering about my experiment using only an r/atom, but I'm ready to disregard that. This is very tricky and tedious to sort out. Only happens on my phone.