Skip to content

Commit 05819fa

Browse files
committed
I chose to break away from the spec of reset! and swap! because there is really no reason to conform to these.
The reactive nodes should not try to mascarade as regular atom, it's not a goal for this lib.
1 parent 13219df commit 05819fa

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

CHANGELOG.md

-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ Signaali is currently [experimental](https://github.com/topics/metosin-experimen
1616

1717
## Unreleased
1818

19-
### Fixed
20-
21-
- `reset!` and `swap!` on a ReactiveNode returns a value similar to when applied to an atom.
2219

2320
## 0.1.0
2421

src/signaali/reactive.cljc

+12-7
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@
151151
(propagation-filter-fn value new-value))
152152
(set! value new-value)
153153
(notify-signal-watchers this true))
154-
value)
154+
;; Value intentionally not returned.
155+
#_value)
155156
,]
156157

157158
:clj [IAtom
@@ -163,17 +164,21 @@
163164
(.reset this (f value a b)))
164165
(swap [this ^IFn f ^Object a ^Object b ^ISeq xs]
165166
(.reset this (apply f value a b xs)))
166-
(^boolean compareAndSet [this ^Object old-value, ^Object new-value]
167-
(if (identical? value old-value)
168-
(do (.reset this new-value)
169-
true)
170-
false))
167+
168+
;; Intentionally not included.
169+
;;(^boolean compareAndSet [this ^Object old-value, ^Object new-value]
170+
;; (if (identical? value old-value)
171+
;; (do (.reset this new-value)
172+
;; true)
173+
;; false))
174+
171175
(reset [this ^Object new-value]
172176
(when (or (nil? propagation-filter-fn)
173177
(propagation-filter-fn value new-value))
174178
(set! value new-value)
175179
(notify-signal-watchers this true))
176-
value)
180+
;; Value intentionally not returned.
181+
#_value)
177182
,])
178183

179184
IDeref

test/signaali/reactive_test.cljc

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
(let [x (sr/create-signal 1)]
1414
(is (= 1 @x))
1515

16-
(let [a (reset! x 5)]
17-
(is (= a 5)))
16+
;; reset! intentionally does not return a meaningful value
17+
(reset! x 5)
1818
(is (= 5 @x))
1919

20-
(let [a (swap! x inc)]
21-
(is (= a 6)))
20+
;; swap! intentionally does not return a meaningful value
21+
(swap! x inc)
2222
(is (= 6 @x)))))
2323

2424
(deftest signal-test

0 commit comments

Comments
 (0)