function | since v1.9.946 | clojure.core/swap-vals! | Edit |

`(swap-vals! a f)`

`(swap-vals! a f x)`

`(swap-vals! a f x y)`

`(swap-vals! a f x y & more)`

Source docstring:

Atomically swaps the value of atom to be: (apply f current-value-of-atom args). Note that f may be called multiple times, and thus should be free of side effects. Returns [old new], the value of the atom before and after the swap.

Source code @ clojurescript:src/main/cljs/cljs/core.cljs

```
(defn swap-vals!
{:added "1.9"}
([a f]
(if (instance? Atom a)
(reset-vals! a (f (.-state a)))
[(-deref a) (-swap! a f)]))
([a f x]
(if (instance? Atom a)
(reset-vals! a (f (.-state a) x))
[(-deref a) (-swap! a f x)]))
([a f x y]
(if (instance? Atom a)
(reset-vals! a (f (.-state a) x y))
[(-deref a) (-swap! a f x y)]))
([a f x y & more]
(if (instance? Atom a)
(reset-vals! a (apply f (.-state a) x y more))
[(-deref a) (-swap! a f x y more)])))
```