Fork me on GitHub
#missionary
<
2023-02-02
>
martinklepsch17:02:26

With a flow like the one below:

(->> (sound/>volume audio-stream)
              (m/eduction (filter pos?))
              (m/reduce (fn [_ v]
                          (when v
                            (js/console.log :use-detect-audio/set-detected v)
                            (set-detected?! true)
                            ;; `reduced` will cancel the flow & audio
                            ;; will no longer be monitored
                            (reduced v))))
              (m.util/run-flow! {}))))
I would expect the reducer function to never be called with anything but positive numbers but I’m seeing that there’s a first call with v being undefined — is this expected? Why is the reducer fn called in that case?

leonoel17:02:21

my guess would be the reducer being called with zero argument to get the initial reducing state, try providing nil as an extra argument to m/reduce