missionary 2024-12-19

Hi, so I’ve been playing around with missionary and it’s really an amazing library. I’m trying to only run (m/reduce) when a value changes. I.e is not equal to it’s previous value. Is there a way to do this? Here’s a rough outline of my code:

(def main
    (let [
Basically, I only want to run the m/reduce if the <result signal value is not equal to the previous <result signal value. Hope that makes sense! Thanks.

cp and latest have this optimization baked in - e.g. (m/latest prn <result) will not print duplicates

you still need m/reduce to sample, but it can be a no-op

(def main
    (let [<result (m/signal (m/latest some-query <db))
          <x (m/latest prn <result)]
      (m/reduce {} nil <x)))
So this? It looks like it works. 🤯

This is so much better than async/event buses. Blown away with how simple it has been to get the actual behaviour I want (once you get over the initial learning curve). Makes writing push based system so much nicer. Thank you!

🖤 1