Skip to content

Commit 3fb8d6c

Browse files
committed
Fixes the return value of reset! and swap!.
1 parent 7c5048a commit 3fb8d6c

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ We use [Break Versioning][breakver]. The version numbers follow a `<major>.<mino
1414

1515
Signaali is currently [experimental](https://github.com/topics/metosin-experimental).
1616

17+
## Unreleased
18+
19+
### Fixed
20+
21+
- `reset!` and `swap!` on a ReactiveNode returns a value similar to when applied to an atom.
22+
1723
## 0.1.0
1824

1925
First release! 🎉

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[![Slack](https://img.shields.io/badge/slack-signaali-orange.svg?logo=slack)](https://clojurians.slack.com/app_redirect?channel=signaali)
1313
[![cljdoc badge](https://cljdoc.org/badge/fi.metosin/signaali)](https://cljdoc.org/d/fi.metosin/signaali)
1414

15-
Signaali is currently [experimental](https://github.com/topics/metosin-experimental).
15+
Signaali is currently [experimental](https://github.com/metosin/open-source/blob/main/project-status.md#experimental).
1616
It works and currently has no known bugs (if you find some, please file an issue),
1717
but we might change its API or namespaces to make it reach maturity.
1818

src/signaali/reactive.cljc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@
150150
(when (or (nil? propagation-filter-fn)
151151
(propagation-filter-fn value new-value))
152152
(set! value new-value)
153-
(notify-signal-watchers this true)))
153+
(notify-signal-watchers this true))
154+
new-value)
154155
,]
155156

156157
:clj [IAtom
@@ -170,8 +171,9 @@
170171
(reset [this ^Object new-value]
171172
(when (or (nil? propagation-filter-fn)
172173
(propagation-filter-fn value new-value))
173-
(-set-value! this new-value)
174-
(notify-signal-watchers this true)))
174+
(set! value new-value)
175+
(notify-signal-watchers this true))
176+
new-value)
175177
,])
176178

177179
IDeref

test/signaali/reactive_test.cljc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
(let [x (sr/create-signal 1)]
1414
(is (= 1 @x))
1515

16-
(reset! x 5)
16+
(let [a (reset! x 5)]
17+
(is (= a 5)))
1718
(is (= 5 @x))
1819

19-
(swap! x inc)
20+
(let [a (swap! x inc)]
21+
(is (= a 6)))
2022
(is (= 6 @x)))))
2123

2224
(deftest signal-test

0 commit comments

Comments
 (0)