I'm having trouble understand how await works on agents.
From the doc string reads
Blocks the current thread (indefinitely!) until all actions dispatched
thus far, from this thread or agent, to the agent(s) have occurred.
So sounds like it should wait for any tasks running on a given agent or any work that agent has dispatched itself (say to other agents or threads). So if I send something then I can await for it to finish.
However, it seems like a watch will also triggers for some reason...
(def bond (agent nil))
(add-watch bond
:test
(fn [_,_,_,_]
(println "pew pew")))
(await bond)
;; the value of bond hasnt changed but it prints "pew pew" ..?
;; can be called an arbitrary number of times - keeps firing
(await bond)
(await bond)
(await bond)
(await bond)
add-watch docs read
Whenever the reference's state might have been changed, any registered watches will have their functions called.
However here the agent's state hasn't changed and yet it's fired
What's going on?