Fork me on GitHub
#missionary
<
2024-03-02
>
Dallas Surewood17:03:05

This is a beginner question, but what exactly does Clojure missionary do that atom watchers don't? It sounds like it essentially allows you to react to atoms with the option of cleaning up the watcher later. Is that the gist of it? Like, couldn't you just attach a watch to an atom updates another atom?

Dallas Surewood08:03:17

I was not saying it's for watching atoms, but that the examples given revolve around having variables that respond to atom changes in a reactive way. Which can be done by adding a watch that updates another atom.

kawas12:03:43

What is the point of any Clojure library? It is to make your coding life easier, to give you syntax, abstractions and tools to manage what you want to do. Same with missionary, it's a library that exposes syntax and tools in order to define, manage and compose "effects". It exposes abstractions to reason about "effects" usage in your code. You can of course build a hierarchy of watchers by yourself and react to atoms changes. Will it be easy to manage, easy to compose? Documentation examples are narrow on purpose to give a taste of what missionary can provide. Don't be distracted by their simplicity, what is to grasp is beyond 😉

leonoel14:03:09

the other major problem solved by missionary is transactional updates - if you try to implement the example from the readme with atom and watches, you will observe inconsistent states aka glitches. It happens when an effect is run in reaction to a change before all the dependencies of this effect have been updated, missionary publishers make sure it's never the case